]> jfr.im git - irc/quakenet/qwebirc.git/blob - bin/dependencies_b.py
Fix many typos in dependency checking.
[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_java()
20 i+=check_hg()
21
22 print "0 errors, %d warnings." % i
23
24 if i == 0:
25 print "looks like you've got everything you need to run qwebirc!"
26 else:
27 print "you can run qwebirc despite these."
28
29 f = open(".checked", "w")
30 f.close()
31
32 def check_win32():
33 if not sys.platform.startswith("win"):
34 return
35
36 try:
37 import win32con
38 except ImportError:
39 fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")
40
41 def check_java():
42 def java_warn(specific):
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/")
44
45 try:
46 p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
47 p.communicate()
48 if p.wait() != 0:
49 java_warn("something went wrong looking for java.")
50 return 1
51 except: # ugh
52 java_warn("couldn't find java.")
53 return 1
54
55 return 0
56
57 def check_hg():
58 def hg_warn(specific):
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/")
60
61 try:
62 p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
63 p.communicate()
64 if p.wait() != 0:
65 hg_warn("something went wrong looking for mercurial.")
66 return 1
67 except: # ugh
68 hg_warn("couldn't find mercurial.")
69 return 1
70
71 return 0
72
73 def check_twisted():
74 try:
75 import twisted
76 except ImportError:
77 fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")
78
79 def twisted_fail(x, y=None):
80 fail("you don't seem to have twisted's %s module." % x,
81 "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))
82
83 try:
84 import twisted.names
85 except ImportError:
86 twisted_fail("names")
87
88 try:
89 import twisted.mail
90 except ImportError:
91 twisted_fail("mail")
92
93 try:
94 import twisted.web
95 except ImportError:
96 twisted_fail("web", "(not web2)")
97
98 try:
99 import twisted.words
100 except ImportError:
101 twisted_fail("words")
102
103 if __name__ == "__main__":
104 import dependencies
105 dependencies.check_dependencies()