]> jfr.im git - irc/quakenet/qwebirc.git/blame - bin/dependencies_b.py
Merge in default.
[irc/quakenet/qwebirc.git] / bin / dependencies_b.py
CommitLineData
a409b906
CP
1# this is seperate to allow us to use python 2.5 syntax without\r
2# the dependency checker breaking on earlier versions.\r
3\r
4import sys\r
5import subprocess\r
6\r
7def fail(*message):\r
8 print >>sys.stderr, "\n".join(message)\r
9 sys.exit(1)\r
10 \r
11def warn(*message):\r
12 print >>sys.stderr, "warning:", "\nwarning: ".join(message), "\n"\r
13\r
14def check_dependencies():\r
15 i = 0\r
16 \r
17 check_twisted()\r
18 check_win32()\r
19 i+=check_java()\r
20 i+=check_hg()\r
21 \r
22 print "0 errors, %d warnings." % i\r
23 \r
24 if i == 0:\r
25 print "looks like you've got everything you need to run qwebirc!"\r
26 else:\r
27 print "you can run qwebirc despite these."\r
28\r
29 f = open(".checked", "w")\r
30 f.close()\r
31 \r
32def check_win32():\r
33 if not sys.platform.startswith("win"):\r
34 return\r
35 \r
36 try:\r
37 import win32con\r
38 except ImportError:\r
39 fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")\r
40 \r
41def check_java():\r
42 def java_warn(specific):\r
43 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
44 \r
45 try:\r
46 p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
47 p.communicate()\r
48 if p.wait() != 0:\r
49 java_warn("something went wrong looking for java.")\r
50 return 1\r
79221dd0 51 except: # ugh\r
a409b906
CP
52 java_warn("couldn't find java.")\r
53 return 1\r
54 \r
55 return 0\r
56 \r
57def check_hg():\r
58 def hg_warn(specific):\r
59 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
60 \r
61 try:\r
62 p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\r
63 p.communicate()\r
64 if p.wait() != 0:\r
65 hg_warn("something went wrong looking for mercurial.")\r
66 return 1\r
79221dd0 67 except: # ugh\r
a409b906
CP
68 hg_warn("couldn't find mercurial.")\r
69 return 1\r
70 \r
71 return 0\r
72 \r
73def check_twisted():\r
74 try:\r
75 import twisted\r
76 except ImportError:\r
77 fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")\r
78\r
79 twisted_fail = lambda x, y=None: fail("you don't seem to have twisted's %s module." % x,\r
80 "your distro is most likely modular, look for a twisted web package%s." % (" %s" % y if y else "",))\r
81\r
82 try:\r
83 import twisted.names\r
84 except ImportError:\r
85 twisted_fail("names")\r
86\r
87 try:\r
88 import twisted.mail\r
89 except ImportError:\r
90 twisted_fail("mail")\r
91 fail("you don't seem to have twisted's mail module, your distro is most likely modular, look for a twisted mail package.")\r
92\r
93 try:\r
94 import twisted.web\r
95 except ImportError:\r
96 twisted_fail("web", "(not web2)")\r
97\r
98 try:\r
99 import twisted.words\r
100 except ImportError:\r
101 twistedfail("words")\r
102\r
103if __name__ == "__main__":\r
104 import dependencies\r
105 dependencies.check_dependencies()\r