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 Ubuntu, you can install %s with:\n" \
45 "sudo apt-get install %s" % (self.module, packageName)
46
47 -class RDF(Dependency):
48 module = 'RDF'
49 name = "Redland RDF Python Bindings"
50 homepage = "http://librdf.org/docs/python.html"
51
53 return "python-redland is not yet available in Fedora Extras.\n"
54
57
59 module = 'Cheetah'
60 name = "Cheetah templating language"
61 homepage = "http://cheetahtemplate.org/"
62
64 if distro.atLeast('4'):
65 return self.FedoraCore_yum('python-cheetah')
66
67 return "python-cheetah is only available in Fedora 4 or newer.\n"
68
71
73 module = 'genshi'
74 name = "Genshi templating language"
75 homepage = "http://genshi.edgewall.com/"
76
78 return "genshi is not yet available in Fedora Extras.\n"
79
82
84 module = 'pygoogle'
85 name = "A Python Interface to the Google API"
86 homepage = "http://pygoogle.sourceforge.net/"
87
89 return "pygoogle is not yet available in Fedora Extras.\n"
90
92 module = 'yahoo'
93 name = "A Python Interface to the Yahoo Web API"
94 homepage = "http://developer.yahoo.com/python/"
95
97 return "python-yahoo is not yet available in Fedora Extras.\n"
98
99 -class trac(Dependency):
100 module = 'trac'
101 name = "Trac issue tracker"
102 homepage = "http://trac.edgewall.com/"
103
109
110
121
123 """
124 Handle dependency import errors by displaying more information about
125 the dependency.
126 """
127 first = exception.args[0]
128 if first.find('No module named ') < 0:
129 raise
130 module = first[len('No module named '):]
131 module = module.split('.')[0]
132 deps = {}
133 for dep in [RDF(), Cheetah(), genshi(), pygoogle(), trac(), yahoo()]:
134 deps[dep.module] = dep
135
136 if module in deps.keys():
137 dep = deps[module]
138 sys.stderr.write("Could not import python module '%s'\n" % module)
139 sys.stderr.write('This module is part of %s.\n' % dep.name)
140
141 handleMissingDependency(dep)
142
143
144 sys.stderr.write(
145 'You can confirm it is installed by starting Python and running:\n')
146 sys.stderr.write('import %s\n' % module)
147
148 return
149
150
151 raise
152
154 reporter = os.environ.get('EMAIL_ADDRESS', None)
155 get = "summary=%s" % urllib.quote(summary)
156 if reporter:
157 get += "&reporter=%s" % urllib.quote(reporter)
158 return 'http://thomas.apestaart.org/moap/trac/newticket?' + get
159
161 if dep.homepage:
162 sys.stderr.write('See %s for more information.\n\n' % dep.homepage)
163
164 d = distro.getDistroFromRelease()
165 if d:
166 howto = dep.install(d)
167 if howto:
168 sys.stderr.write(howto)
169 else:
170 url = getTicketURL('DEP: %s, %s' % (dep.module, d.description))
171 sys.stderr.write("""On %s, MOAP does not know how to install %s.
172 Please file a bug at:
173 %s
174 with instructions on how to install the dependency so we can add it.
175 """ % (d.description, dep.module, url))
176 else:
177 url = getTicketURL('DISTRO: Unknown')
178 sys.stderr.write("""MOAP does not know your distribution.
179 Please file a bug at:
180 %s
181 with instructions on how to recognize your distribution so we can add it.
182 """ % url)
183
184 sys.stderr.write('\n')
185
186 sys.stderr.write('Please install %s and try again.\n' % dep.module)
187