]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - bin/dependencies_b.py
Merge.
[irc/quakenet/qwebirc.git] / bin / dependencies_b.py
index 3ea7c4b8ab7a84d16e5a3200407a6ca001e1f360..e02e875cba1f7417ab35450ad2662605572ed0f2 100644 (file)
@@ -1,8 +1,9 @@
-# this is seperate to allow us to use python 2.5 syntax without\r
+# this is separate to allow us to use python 2.5 syntax without\r
 # the dependency checker breaking on earlier versions.\r
 \r
 import sys\r
 import subprocess\r
+import os\r
 \r
 def fail(*message):\r
   print >>sys.stderr, "\n".join(message)\r
@@ -15,10 +16,13 @@ def check_dependencies():
   i = 0\r
   \r
   check_twisted()\r
+  check_zope()\r
   check_win32()\r
+  i+=check_autobahn()\r
+  i+=check_json()\r
   i+=check_java()\r
   i+=check_hg()\r
-  \r
+\r
   print "0 errors, %d warnings." % i\r
   \r
   if i == 0:\r
@@ -43,12 +47,12 @@ def check_java():
     warn(specific, "java is not required, but allows qwebirc to compress output,", "making it faster to download.", "you can get java at http://www.java.com/")\r
     \r
   try:\r
-    p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
     p.communicate()\r
     if p.wait() != 0:\r
       java_warn("something went wrong looking for java.")\r
       return 1\r
-  except WindowsError:\r
+  except: # ugh\r
     java_warn("couldn't find java.")\r
     return 1\r
     \r
@@ -59,25 +63,38 @@ def check_hg():
     warn(specific, "mercurial (hg) is not required, but allows qwebirc to save bandwidth by versioning.", "you can get hg at http://www.selenic.com/mercurial/")\r
     \r
   try:\r
-    p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
+    p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
     p.communicate()\r
     if p.wait() != 0:\r
       hg_warn("something went wrong looking for mercurial.")\r
       return 1\r
-  except WindowsError:\r
+  except: # ugh\r
     hg_warn("couldn't find mercurial.")\r
     return 1\r
     \r
   return 0\r
   \r
+def check_zope():\r
+  try:\r
+    from zope.interface import Interface\r
+  except ImportError:\r
+    if sys.platform.startswith("win"):\r
+      fail("qwebirc requires zope interface",\r
+           "see pypi: http://pypi.python.org/pypi/zope.interface")\r
+    else:\r
+      fail("qwebirc requires zope interface.",\r
+           "this should normally come with twisted, but can be downloaded",\r
+           "from pypi: http://pypi.python.org/pypi/zope.interface")\r
+\r
 def check_twisted():\r
   try:\r
     import twisted\r
   except ImportError:\r
     fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")\r
 \r
-  twisted_fail = lambda x, y=None: fail("you don't seem to have twisted's %s module." % x,\r
-                                        "your distro is most likely modular, look for a twisted web package%s." % (" %s" % y if y else "",))\r
+  def twisted_fail(x, y=None):\r
+    fail("you don't seem to have twisted's %s module." % x,\r
+         "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))\r
 \r
   try:\r
     import twisted.names\r
@@ -88,7 +105,6 @@ def check_twisted():
     import twisted.mail\r
   except ImportError:\r
     twisted_fail("mail")\r
-    fail("you don't seem to have twisted's mail module, your distro is most likely modular, look for a twisted mail package.")\r
 \r
   try:\r
     import twisted.web\r
@@ -98,7 +114,31 @@ def check_twisted():
   try:\r
     import twisted.words\r
   except ImportError:\r
-    twistedfail("words")\r
+    twisted_fail("words")\r
+    \r
+def check_json():\r
+  import qwebirc.util.qjson\r
+  if qwebirc.util.qjson.slow:\r
+    warn("simplejson module with C speedups not installed.",\r
+         "using embedded module (slower); consider installing simplejson from:",\r
+         "http://pypi.python.org/pypi/simplejson/")\r
+    return 1\r
+  return 0\r
+\r
+def check_autobahn():\r
+  try:\r
+    import autobahn, autobahn.websocket\r
+    x = autobahn.version.split(".")\r
+    if len(x) != 3:\r
+      raise ImportError("Unknown version: %s", autobahn.vesrion)\r
+    if (int(x[1]) < 8) or (int(x[1]) == 8 and int(x[2]) < 14):\r
+      raise ImportError()\r
+    return 0\r
+  except ImportError:\r
+    warn("autobahn 0.8.14 (minimum) not installed; websocket support will be disabled.",\r
+         "consider installing autobahn from:",\r
+         "http://autobahn.ws/python/getstarted/")\r
+    return 1\r
 \r
 if __name__ == "__main__":\r
   import dependencies\r