[tor-commits] [arm/master] Provide prereq installation suggestions for the user's platform

atagar at torproject.org atagar at torproject.org
Tue Mar 31 02:42:30 UTC 2015


commit d62806124bc9fcd6d18ba86ef52274e83ac92656
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Mar 29 23:17:48 2015 -0700

    Provide prereq installation suggestions for the user's platform
---
 run_nyx |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/run_nyx b/run_nyx
index efa080d..b1b6403 100755
--- a/run_nyx
+++ b/run_nyx
@@ -2,6 +2,7 @@
 # Copyright 2014, Damian Johnson and The Tor Project
 # See LICENSE for licensing information
 
+import distutils.spawn
 import sys
 
 import nyx.starter
@@ -35,12 +36,24 @@ def _check_prereq():
   try:
     import stem
   except ImportError:
-    raise ImportError("nyx requires stem, try running 'sudo apt-get install python-stem'")
+    if distutils.spawn.find_executable('pip') is not None:
+      advice = "try running 'sudo pip install stem'"
+    elif distutils.spawn.find_executable('apt-get') is not None:
+      advice = "try running 'sudo apt-get install python-stem'"
+    else:
+      advice = "you can find it at https://stem.torproject.org/download.html"
+
+    raise ImportError("nyx requires stem, %s" % advice)
 
   try:
     import curses
   except ImportError:
-    raise ImportError("nyx requires curses, try running 'sudo apt-get install python-curses'")
+    if distutils.spawn.find_executable('apt-get') is not None:
+      advice = ", try running 'sudo apt-get install python-curses'"
+    else:
+      advice = ''  # not sure what to do for other platforms
+
+    raise ImportError("nyx requires curses" + advice)
 
 
 if __name__ == '__main__':



More information about the tor-commits mailing list