commit 0c6fcdfaca98fede097d970fa42a3406e63bb334 Author: Damian Johnson atagar@torproject.org Date: Fri Jun 10 08:34:28 2011 -0700
fix: checking cli or gui prereqs based on args
This only checks for curses dependencies if running the cli and gtk dependencies when running the gui. This isn't quite an ideal solution since it duplicates the gui args in prereq.py but not the end of the world. --- arm | 2 +- src/prereq.py | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/arm b/arm index de0b248..a6dba93 100755 --- a/arm +++ b/arm @@ -5,7 +5,7 @@ else arm_base=$( dirname "$0" )/src/ fi
-python "${arm_base}prereq.py" +python "${arm_base}prereq.py" $*
if [ $? = 0 ]; then exec python -W ignore::DeprecationWarning "${arm_base}starter.py" $* diff --git a/src/prereq.py b/src/prereq.py index 506a4b0..93d9de3 100644 --- a/src/prereq.py +++ b/src/prereq.py @@ -133,7 +133,11 @@ def installCagraph(): # of errors. shutil.rmtree(tmpDir, ignore_errors=True)
-if __name__ == '__main__': +def allPrereq(): + """ + Requrements for both the cli and gui versions of arm. + """ + majorVersion = sys.version_info[0] minorVersion = sys.version_info[1]
@@ -144,17 +148,42 @@ if __name__ == '__main__': print("arm requires python version 2.5 or greater\n") sys.exit(1)
+ if not isTorCtlAvailable(): + isInstalled = promptTorCtlInstall() + if not isInstalled: sys.exit(1) + +def cliPrereq(): + """ + Requirements for the cli arm interface. + """ + + allPrereq() + try: import curses except ImportError: print("arm requires curses - try installing the python-curses package\n") sys.exit(1) - - if not isTorCtlAvailable(): - isInstalled = promptTorCtlInstall() - if not isInstalled: sys.exit(1)
+def guiPrereq(): + """ + Requirements for the gui arm interface. + """ + + allPrereq() + + try: + import gtk + except ImportError: + print("arm requires gtk - try installing the python-gtk2 package\n") + sys.exit(1) + if not isCagraphAvailable(): isInstalled = promptCagraphInstall() if not isInstalled: sys.exit(1)
+if __name__ == '__main__': + isGui = "-g" in sys.argv or "--gui" in sys.argv + if isGui: guiPrereq() + else: cliPrereq() +
tor-commits@lists.torproject.org