]>
Commit | Line | Data |
---|---|---|
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 | |
4 | import sys\r | |
5 | import subprocess\r | |
6 | \r | |
7 | def fail(*message):\r | |
8 | print >>sys.stderr, "\n".join(message)\r | |
9 | sys.exit(1)\r | |
10 | \r | |
11 | def warn(*message):\r | |
12 | print >>sys.stderr, "warning:", "\nwarning: ".join(message), "\n"\r | |
13 | \r | |
14 | def check_dependencies():\r | |
15 | i = 0\r | |
16 | \r | |
17 | check_twisted()\r | |
3d0a1458 | 18 | check_zope()\r |
a409b906 | 19 | check_win32()\r |
c60795d6 | 20 | i+=check_autobahn()\r |
becfa850 | 21 | i+=check_json()\r |
a409b906 CP |
22 | i+=check_java()\r |
23 | i+=check_hg()\r | |
c60795d6 | 24 | \r |
a409b906 CP |
25 | print "0 errors, %d warnings." % i\r |
26 | \r | |
27 | if i == 0:\r | |
28 | print "looks like you've got everything you need to run qwebirc!"\r | |
29 | else:\r | |
30 | print "you can run qwebirc despite these."\r | |
31 | \r | |
32 | f = open(".checked", "w")\r | |
33 | f.close()\r | |
34 | \r | |
35 | def check_win32():\r | |
36 | if not sys.platform.startswith("win"):\r | |
37 | return\r | |
38 | \r | |
39 | try:\r | |
40 | import win32con\r | |
41 | except ImportError:\r | |
42 | fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")\r | |
43 | \r | |
44 | def check_java():\r | |
45 | def java_warn(specific):\r | |
46 | 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 | |
47 | \r | |
48 | try:\r | |
f99fa3ee | 49 | p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r |
a409b906 CP |
50 | p.communicate()\r |
51 | if p.wait() != 0:\r | |
52 | java_warn("something went wrong looking for java.")\r | |
53 | return 1\r | |
79221dd0 | 54 | except: # ugh\r |
a409b906 CP |
55 | java_warn("couldn't find java.")\r |
56 | return 1\r | |
57 | \r | |
58 | return 0\r | |
59 | \r | |
60 | def check_hg():\r | |
61 | def hg_warn(specific):\r | |
62 | 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 | |
63 | \r | |
64 | try:\r | |
f99fa3ee | 65 | p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r |
a409b906 CP |
66 | p.communicate()\r |
67 | if p.wait() != 0:\r | |
68 | hg_warn("something went wrong looking for mercurial.")\r | |
69 | return 1\r | |
79221dd0 | 70 | except: # ugh\r |
a409b906 CP |
71 | hg_warn("couldn't find mercurial.")\r |
72 | return 1\r | |
73 | \r | |
74 | return 0\r | |
75 | \r | |
3d0a1458 CP |
76 | def check_zope():\r |
77 | try:\r | |
78 | from zope.interface import Interface\r | |
79 | except ImportError:\r | |
80 | if sys.platform.startswith("win"):\r | |
81 | fail("qwebirc requires zope interface",\r | |
82 | "see pypi: http://pypi.python.org/pypi/zope.interface")\r | |
83 | else:\r | |
84 | fail("qwebirc requires zope interface.",\r | |
85 | "this should normally come with twisted, but can be downloaded",\r | |
86 | "from pypi: http://pypi.python.org/pypi/zope.interface")\r | |
c60795d6 | 87 | \r |
a409b906 CP |
88 | def check_twisted():\r |
89 | try:\r | |
90 | import twisted\r | |
91 | except ImportError:\r | |
92 | fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")\r | |
93 | \r | |
0d221e0f CP |
94 | def twisted_fail(x, y=None):\r |
95 | fail("you don't seem to have twisted's %s module." % x,\r | |
96 | "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))\r | |
a409b906 CP |
97 | \r |
98 | try:\r | |
99 | import twisted.names\r | |
100 | except ImportError:\r | |
101 | twisted_fail("names")\r | |
102 | \r | |
103 | try:\r | |
104 | import twisted.mail\r | |
105 | except ImportError:\r | |
106 | twisted_fail("mail")\r | |
a409b906 CP |
107 | \r |
108 | try:\r | |
109 | import twisted.web\r | |
110 | except ImportError:\r | |
111 | twisted_fail("web", "(not web2)")\r | |
112 | \r | |
113 | try:\r | |
114 | import twisted.words\r | |
115 | except ImportError:\r | |
0d221e0f | 116 | twisted_fail("words")\r |
becfa850 CP |
117 | \r |
118 | def check_json():\r | |
119 | import qwebirc.util.qjson\r | |
120 | if qwebirc.util.qjson.slow:\r | |
121 | warn("simplejson module with C speedups not installed.",\r | |
122 | "using embedded module (slower); consider installing simplejson from:",\r | |
123 | "http://pypi.python.org/pypi/simplejson/")\r | |
124 | return 1\r | |
125 | return 0\r | |
c60795d6 CP |
126 | \r |
127 | def check_autobahn():\r | |
128 | try:\r | |
129 | import autobahn.websocket\r | |
c60795d6 | 130 | return 0\r |
7d179b4e CP |
131 | except ImportError:\r |
132 | warn("autobahn not installed; websocket support will be disabled.",\r | |
133 | "consider installing autobahn from:",\r | |
134 | "http://autobahn.ws/python/getstarted/")\r | |
135 | return 1\r | |
c60795d6 | 136 | \r |
a409b906 CP |
137 | if __name__ == "__main__":\r |
138 | import dependencies\r | |
139 | dependencies.check_dependencies()\r |