+# this is seperate 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
+\r
+def fail(*message):\r
+ print >>sys.stderr, "\n".join(message)\r
+ sys.exit(1)\r
+ \r
+def warn(*message):\r
+ print >>sys.stderr, "warning:", "\nwarning: ".join(message), "\n"\r
+\r
+def check_dependencies():\r
+ i = 0\r
+ \r
+ check_twisted()\r
+ check_win32()\r
+ i+=check_java()\r
+ i+=check_hg()\r
+ \r
+ print "0 errors, %d warnings." % i\r
+ \r
+ if i == 0:\r
+ print "looks like you've got everything you need to run qwebirc!"\r
+ else:\r
+ print "you can run qwebirc despite these."\r
+\r
+ f = open(".checked", "w")\r
+ f.close()\r
+ \r
+def check_win32():\r
+ if not sys.platform.startswith("win"):\r
+ return\r
+ \r
+ try:\r
+ import win32con\r
+ except ImportError:\r
+ fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")\r
+ \r
+def check_java():\r
+ def java_warn(specific):\r
+ 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.communicate()\r
+ if p.wait() != 0:\r
+ java_warn("something went wrong looking for java.")\r
+ return 1\r
+ except WindowsError:\r
+ java_warn("couldn't find java.")\r
+ return 1\r
+ \r
+ return 0\r
+ \r
+def check_hg():\r
+ def hg_warn(specific):\r
+ 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.communicate()\r
+ if p.wait() != 0:\r
+ hg_warn("something went wrong looking for mercurial.")\r
+ return 1\r
+ except WindowsError:\r
+ hg_warn("couldn't find mercurial.")\r
+ return 1\r
+ \r
+ return 0\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
+\r
+ try:\r
+ import twisted.names\r
+ except ImportError:\r
+ twisted_fail("names")\r
+\r
+ try:\r
+ 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
+ except ImportError:\r
+ twisted_fail("web", "(not web2)")\r
+\r
+ try:\r
+ import twisted.words\r
+ except ImportError:\r
+ twistedfail("words")\r
+\r
+if __name__ == "__main__":\r
+ import dependencies\r
+ dependencies.check_dependencies()\r