[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Putting TorCtl install prompt in its own function



commit 6534807224d5f88b0c5450e996e5fa1f8c470763
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Apr 21 08:52:36 2011 -0700

    Putting TorCtl install prompt in its own function
---
 src/prereq.py |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/prereq.py b/src/prereq.py
index ee5c768..50aaa91 100644
--- a/src/prereq.py
+++ b/src/prereq.py
@@ -20,6 +20,30 @@ def isTorCtlAvailable():
   except ImportError:
     return False
 
+def promptTorCtlInstall():
+  """
+  Asks the user to install TorCtl. This returns True if it was installed and
+  False otherwise (if it was either declined or failed to be fetched.
+  """
+  
+  userInput = raw_input("Arm requires TorCtl to run, but it's unavailable. Would you like to install it? (y/n): ")
+  
+  # if user says no then terminate
+  if not userInput.lower() in ("y", "yes"): return False
+  
+  # attempt to install TorCtl, printing the issue if unsuccessful
+  try:
+    installTorCtl()
+    
+    if not isTorCtlAvailable():
+      raise IOError("Unable to install TorCtl, sorry")
+    
+    print "TorCtl successfully installed"
+    return True
+  except IOError, exc:
+    print exc
+    return False
+
 def installTorCtl():
   """
   Checks out the current git head release for TorCtl and bundles it with arm.
@@ -65,19 +89,6 @@ if __name__ == '__main__':
     sys.exit(1)
   
   if not isTorCtlAvailable():
-    userInput = raw_input("Arm requires TorCtl to run, but it's unavailable. Would you like to install it? (y/n): ")
-    
-    # if user says no then terminate
-    if not userInput.lower() in ("y", "yes"):
-      sys.exit(1)
-    
-    # attempt to install TorCtl, printing the issue if unsuccessful
-    try:
-      installTorCtl()
-      
-      if not isTorCtlAvailable():
-        raise IOError("Unable to install TorCtl, sorry")
-    except IOError, exc:
-      print exc
-      sys.exit(1)
+    isInstalled = promptTorCtlInstall()
+    if not isInstalled: sys.exit(1)
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits