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