1
2
3
4
5
6
7 import os
8 import sys
9 import urllib
10
11 from moap.util import distro
12
14 module = None
15 name = None
16 homepage = None
17
19 """
20 Return an explanation on how to install the given dependency
21 for the given distro/version/arch.
22
23 @type distro: L{distro.Distro}
24
25 @rtype: str or None
26 @returns: an explanation on how to install the dependency, or None.
27 """
28 name = distro.distributor + '_install'
29 m = getattr(self, name, None)
30 if m:
31 return m(distro)
32
34 """
35 Returns a string explaining how to install the given package.
36 """
37 return "On Fedora, you can install %s with:\n" \
38 "su -c \"yum install %s\"" % (self.module, packageName)
39
41 """
42 Returns a string explaining how to install the given package.
43 """
44 return "On Debian, you can install %s with:\n" \
45 "sudo apt-get install %s" % (self.module, packageName)
46
48 """
49 Returns a string explaining how to install the given package.
50 """
51 return "On Ubuntu, you can install %s with:\n" \
52 "sudo apt-get install %s" % (self.module, packageName)
53
54 -class RDF(Dependency):
55 module = 'RDF'
56 name = "Redland RDF Python Bindings"
57 homepage = "http://librdf.org/docs/python.html"
58
60 return "python-redland is not yet available in Fedora Extras.\n"
61
64
66 module = 'Cheetah'
67 name = "Cheetah templating language"
68 homepage = "http://cheetahtemplate.org/"
69
71 if distro.atLeast('4'):
72 return self.FedoraCore_yum('python-cheetah')
73
74 return "python-cheetah is only available in Fedora 4 or newer.\n"
75
78
80 module = 'genshi'
81 name = "Genshi templating language"
82 homepage = "http://genshi.edgewall.com/"
83
85 return "genshi is not yet available in Fedora Extras.\n"
86
89
91 module = 'pygoogle'
92 name = "A Python Interface to the Google API"
93 homepage = "http://pygoogle.sourceforge.net/"
94
96 return "pygoogle is not yet available in Fedora Extras.\n"
97
99 module = 'yahoo'
100 name = "A Python Interface to the Yahoo Web API"
101 homepage = "http://developer.yahoo.com/python/"
102
104 return "python-yahoo is not yet available in Fedora Extras.\n"
105
108
109 -class trac(Dependency):
110 module = 'trac'
111 name = "Trac issue tracker"
112 homepage = "http://trac.edgewall.com/"
113
119
120
131
133 """
134 Handle dependency import errors by displaying more information about
135 the dependency.
136 """
137 first = exception.args[0]
138 if first.find('No module named ') < 0:
139 raise
140 module = first[len('No module named '):]
141 module = module.split('.')[0]
142 deps = {}
143 for dep in [RDF(), Cheetah(), genshi(), pygoogle(), trac(), yahoo()]:
144 deps[dep.module] = dep
145
146 if module in deps.keys():
147 dep = deps[module]
148 sys.stderr.write("Could not import python module '%s'\n" % module)
149 sys.stderr.write('This module is part of %s.\n' % dep.name)
150
151 handleMissingDependency(dep)
152
153
154 sys.stderr.write(
155 'You can confirm it is installed by starting Python and running:\n')
156 sys.stderr.write('import %s\n' % module)
157
158 return
159
160
161 raise
162
164 reporter = os.environ.get('EMAIL_ADDRESS', None)
165 get = "summary=%s" % urllib.quote(summary)
166 if reporter:
167 get += "&reporter=%s" % urllib.quote(reporter)
168 return 'http://thomas.apestaart.org/moap/trac/newticket?' + get
169
171 if dep.homepage:
172 sys.stderr.write('See %s for more information.\n\n' % dep.homepage)
173
174 d = distro.getDistroFromRelease()
175 if d:
176 howto = dep.install(d)
177 if howto:
178 sys.stderr.write(howto)
179 else:
180 url = getTicketURL('DEP: %s, %s' % (dep.module, d.description))
181 sys.stderr.write("""On %s, MOAP does not know how to install %s.
182 Please file a bug at:
183 %s
184 with instructions on how to install the dependency so we can add it.
185 """ % (d.description, dep.module, url))
186 else:
187 url = getTicketURL('DISTRO: Unknown')
188 sys.stderr.write("""MOAP does not know your distribution.
189 Please file a bug at:
190 %s
191 with instructions on how to recognize your distribution so we can add it.
192 """ % url)
193
194 sys.stderr.write('\n')
195
196 sys.stderr.write('Please install %s and try again.\n' % dep.module)
197