[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Dropping the old prompt
commit 29e7524d4e54baa26022597793ad84c2df9031ff
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sat May 10 17:48:53 2014 -0700
Dropping the old prompt
Our new prompt does everything the old one does and much more. Dropping the old
prompt command.
---
prompt_old | 19 -----------
test/prompt.py | 102 --------------------------------------------------------
2 files changed, 121 deletions(-)
diff --git a/prompt_old b/prompt_old
deleted file mode 100755
index c1ba961..0000000
--- a/prompt_old
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# Provides a quick method of getting a controller that we can use to test stem
-# with. This starts tor if it isn't already running and provides us with a
-# controller instance. When done it gives us the option to stop the tor.
-#
-# atagar@morrigan:~/Desktop/stem$ ./prompt
-# Welcome to stem's testing prompt. You currently have a controller available
-# via the 'controller' variable.
-#
-# >>> controller.get_info("version")
-# '0.2.1.30'
-# >>> quit()
-#
-# Would you like to stop the tor instance we made? (y/n, default: n): y
-
-python -i -c "import test.prompt; test.prompt.print_usage(); controller = test.prompt.controller()"
-python -c "import test.prompt; test.prompt.stop(True)"
-
diff --git a/test/prompt.py b/test/prompt.py
deleted file mode 100644
index 278f2d6..0000000
--- a/test/prompt.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright 2012-2014, Damian Johnson and The Tor Project
-# See LICENSE for licensing information
-
-"""
-Simple helper methods to make troubleshooting with the python interpreter
-easier.
-
-::
-
- >>> from test.prompt import *
- >>> controller = controller()
- >>> controller.get_info("version")
- '0.2.1.30'
-
- >>> is_running()
- True
-
- >>> stop()
-"""
-
-import os
-import signal
-import sys
-
-import stem.control
-import stem.process
-import stem.util.system
-
-CONTROL_PORT = 2779
-
-STOP_CONFIRMATION = "Would you like to stop the tor instance we made? (y/n, default: n): "
-
-
-def print_usage():
- """
- Provides a welcoming message.
- """
-
- print "Welcome to stem's testing prompt. You currently have a controller available"
- print "via the 'controller' variable."
- print
-
-
-def start():
- """
- Starts up a tor instance that we can attach a controller to.
- """
-
- tor_config = {
- 'SocksPort': '0',
- 'ControlPort': str(CONTROL_PORT),
- 'ExitPolicy': 'reject *:*',
- }
-
- sys.stdout.write("Starting tor...")
- stem.process.launch_tor_with_config(config = tor_config, completion_percent = 5)
- sys.stdout.write(" done\n\n")
-
-
-def stop(prompt = False):
- """
- Stops the tor instance spawned by this module.
-
- :param bool prompt: asks user for confirmation that they would like to stop tor if True
- """
-
- tor_pid = stem.util.system.get_pid_by_port(CONTROL_PORT)
-
- if tor_pid:
- if prompt:
- response = raw_input("\n" + STOP_CONFIRMATION)
-
- if not response.lower() in ("y", "yes"):
- return
-
- os.kill(tor_pid, signal.SIGTERM)
-
-
-def is_running():
- """
- Checks if we're likely running a tor instance spawned by this module. This is
- simply a check if our custom control port is in use, so it can be confused by
- other applications (not likely, but possible).
-
- :returns: True if the control port is used, False otherwise
- """
-
- return bool(stem.util.system.get_pid_by_port(CONTROL_PORT))
-
-
-def controller():
- """
- Provides a Controller for our tor instance. This starts tor if it isn't
- already running.
- """
-
- if not is_running():
- start()
-
- controller = stem.control.Controller.from_port(port = CONTROL_PORT)
- controller.authenticate()
- return controller
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits