Status: | Merged |
---|---|
Merged at revision: | 442 |
Proposed branch: | lp:~mvo/gdebi/py3compat |
Merge into: | lp:gdebi |
Diff against target: |
888 lines (+251/-131) 16 files modified
GDebi/DebPackage.py (+6/-2) GDebi/GDebiCli.py (+22/-17) GDebi/GDebiCommon.py (+11/-12) GDebi/GDebiGtk.py (+38/-39) GDebi/GDebiKDE.py (+50/-24) GDebi/KDEAptDialogs.py (+23/-26) GDebi/SimpleGtkbuilderApp.py (+0/-3) debian/control (+1/-0) gdebi (+1/-1) gdebi-gtk (+4/-4) gdebi-kde (+1/-1) po/POTFILES.in (+1/-1) setup.py (+2/-1) tests/test_gdebi_cli.py (+42/-0) tests/test_gdebi_gtk.py (+34/-0) tests/test_pyflakes.py (+15/-0) |
To merge this branch: | bzr merge lp:~mvo/gdebi/py3compat |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
gdebi-developers | Pending | ||
Review via email: mp+129383@code.launchpad.net |
Commit message
Description of the change
I started looking into a py3 port (or py3 compatiblity) and started some small porting and also started adding automatic tests to ensure I don't break stuff while porting. Low risk at this point for trunk I think and probably
a useful way to get more tests and better compatibility over time.
To post a comment you must log in.
lp:~mvo/gdebi/py3compat
updated
- 443. By Michael Vogt
-
use relative imports (supported since python2.5)
- 444. By Michael Vogt
-
pyflake fixes and add test that runs automatically to ensure we stay pyflakes clean :)
- 445. By Michael Vogt
-
gdebi-gtk: remove accidental commit
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'GDebi/DebPackage.py' | |||
2 | --- GDebi/DebPackage.py 2011-06-12 13:54:38 +0000 | |||
3 | +++ GDebi/DebPackage.py 2012-10-12 16:06:23 +0000 | |||
4 | @@ -24,7 +24,6 @@ | |||
5 | 24 | import apt.debfile | 24 | import apt.debfile |
6 | 25 | from gettext import gettext as _ | 25 | from gettext import gettext as _ |
7 | 26 | 26 | ||
8 | 27 | from apt.debfile import DscSrcPackage | ||
9 | 28 | 27 | ||
10 | 29 | class DebPackage(apt.debfile.DebPackage): | 28 | class DebPackage(apt.debfile.DebPackage): |
11 | 30 | 29 | ||
12 | @@ -33,8 +32,13 @@ | |||
13 | 33 | self.downloaded = downloaded | 32 | self.downloaded = downloaded |
14 | 34 | 33 | ||
15 | 35 | def __getitem__(self,item): | 34 | def __getitem__(self,item): |
17 | 36 | if not self._sections.has_key(item): | 35 | if not item in self._sections: |
18 | 37 | # Translators: it's for missing entries in the deb package, | 36 | # Translators: it's for missing entries in the deb package, |
19 | 38 | # e.g. a missing "Maintainer" field | 37 | # e.g. a missing "Maintainer" field |
20 | 39 | return _("%s is not available") % item | 38 | return _("%s is not available") % item |
21 | 40 | return self._sections[item] | 39 | return self._sections[item] |
22 | 40 | |||
23 | 41 | |||
24 | 42 | # just for compatibility | ||
25 | 43 | class DscSrcPackage(apt.debfile.DscSrcPackage): | ||
26 | 44 | pass | ||
27 | 41 | 45 | ||
28 | === modified file 'GDebi/GDebiCli.py' | |||
29 | --- GDebi/GDebiCli.py 2012-10-11 20:09:58 +0000 | |||
30 | +++ GDebi/GDebiCli.py 2012-10-12 16:06:23 +0000 | |||
31 | @@ -23,20 +23,18 @@ | |||
32 | 23 | 23 | ||
33 | 24 | import apt | 24 | import apt |
34 | 25 | import apt_pkg | 25 | import apt_pkg |
36 | 26 | import fcntl | 26 | import logging |
37 | 27 | import os | 27 | import os |
38 | 28 | import string | ||
39 | 29 | import sys | 28 | import sys |
40 | 30 | import time | ||
41 | 31 | import thread | ||
42 | 32 | 29 | ||
43 | 33 | from gettext import gettext as _ | 30 | from gettext import gettext as _ |
44 | 34 | from re import findall | 31 | from re import findall |
45 | 32 | from subprocess import PIPE, Popen, call | ||
46 | 35 | 33 | ||
47 | 36 | from apt.cache import Cache | 34 | from apt.cache import Cache |
51 | 37 | from DebPackage import DebPackage, DscSrcPackage | 35 | |
52 | 38 | 36 | from .DebPackage import DebPackage, DscSrcPackage | |
53 | 39 | from subprocess import PIPE, Popen, call | 37 | |
54 | 40 | 38 | ||
55 | 41 | class GDebiCli(object): | 39 | class GDebiCli(object): |
56 | 42 | 40 | ||
57 | @@ -77,7 +75,8 @@ | |||
58 | 77 | else: | 75 | else: |
59 | 78 | sys.stderr.write(_("Unknown package type '%s', exiting\n") % file) | 76 | sys.stderr.write(_("Unknown package type '%s', exiting\n") % file) |
60 | 79 | sys.exit(1) | 77 | sys.exit(1) |
62 | 80 | except (IOError,SystemError,ValueError),e: | 78 | except (IOError,SystemError,ValueError) as e: |
63 | 79 | logging.debug("error opening: %s" % e) | ||
64 | 81 | sys.stderr.write(_("Failed to open the software package\n")) | 80 | sys.stderr.write(_("Failed to open the software package\n")) |
65 | 82 | sys.stderr.write(_("The package might be corrupted or you are not " | 81 | sys.stderr.write(_("The package might be corrupted or you are not " |
66 | 83 | "allowed to open the file. Check the permissions " | 82 | "allowed to open the file. Check the permissions " |
67 | @@ -97,22 +96,27 @@ | |||
68 | 97 | print _("No description is available") | 96 | print _("No description is available") |
69 | 98 | 97 | ||
70 | 99 | def show_dependencies(self): | 98 | def show_dependencies(self): |
71 | 99 | print self.get_dependencies_info() | ||
72 | 100 | |||
73 | 101 | def get_dependencies_info(self): | ||
74 | 102 | s = "" | ||
75 | 100 | # show what changes | 103 | # show what changes |
76 | 101 | (install, remove, unauthenticated) = self._deb.required_changes | 104 | (install, remove, unauthenticated) = self._deb.required_changes |
77 | 102 | if len(unauthenticated) > 0: | 105 | if len(unauthenticated) > 0: |
79 | 103 | print _("The following packages are UNAUTHENTICATED: ") | 106 | s += _("The following packages are UNAUTHENTICATED: ") |
80 | 104 | for pkgname in unauthenticated: | 107 | for pkgname in unauthenticated: |
82 | 105 | print pkgname + " ", | 108 | s += pkgname + " " |
83 | 106 | if len(remove) > 0: | 109 | if len(remove) > 0: |
85 | 107 | print _("Requires the REMOVAL of the following packages: ") | 110 | s += _("Requires the REMOVAL of the following packages: ") |
86 | 108 | for pkgname in remove: | 111 | for pkgname in remove: |
89 | 109 | print pkgname + " ", | 112 | s += pkgname + " " |
90 | 110 | 113 | s += "\n" | |
91 | 111 | if len(install) > 0: | 114 | if len(install) > 0: |
93 | 112 | print _("Requires the installation of the following packages: ") | 115 | s += _("Requires the installation of the following packages: ") |
94 | 113 | for pkgname in install: | 116 | for pkgname in install: |
97 | 114 | print pkgname + " ", | 117 | s += pkgname + " " |
98 | 115 | 118 | s += "\n" | |
99 | 119 | return s | ||
100 | 116 | 120 | ||
101 | 117 | def install(self): | 121 | def install(self): |
102 | 118 | # install the dependecnies | 122 | # install the dependecnies |
103 | @@ -122,7 +126,8 @@ | |||
104 | 122 | iprogress = apt.progress.base.InstallProgress() | 126 | iprogress = apt.progress.base.InstallProgress() |
105 | 123 | try: | 127 | try: |
106 | 124 | res = self._cache.commit(fprogress,iprogress) | 128 | res = self._cache.commit(fprogress,iprogress) |
108 | 125 | except(apt.cache.FetchFailedException, SystemError) e: | 129 | logging.debug("commit() returned %s" % res) |
109 | 130 | except(apt.cache.FetchFailedException, SystemError) as e: | ||
110 | 126 | sys.stderr.write(_("Error during install: '%s'") % e) | 131 | sys.stderr.write(_("Error during install: '%s'") % e) |
111 | 127 | return 1 | 132 | return 1 |
112 | 128 | 133 | ||
113 | 129 | 134 | ||
114 | === modified file 'GDebi/GDebiCommon.py' | |||
115 | --- GDebi/GDebiCommon.py 2012-09-12 21:28:17 +0000 | |||
116 | +++ GDebi/GDebiCommon.py 2012-10-12 16:06:23 +0000 | |||
117 | @@ -21,24 +21,21 @@ | |||
118 | 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
119 | 22 | # | 22 | # |
120 | 23 | 23 | ||
123 | 24 | 24 | import gettext | |
124 | 25 | import sys | 25 | import logging |
125 | 26 | import os | 26 | import os |
126 | 27 | import string | ||
127 | 28 | import warnings | ||
128 | 29 | warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) | ||
129 | 30 | from mimetypes import guess_type | 27 | from mimetypes import guess_type |
130 | 31 | 28 | ||
131 | 32 | import apt | ||
132 | 33 | import apt_pkg | 29 | import apt_pkg |
133 | 34 | |||
134 | 35 | from apt.cache import Cache | 30 | from apt.cache import Cache |
137 | 36 | from DebPackage import DebPackage | 31 | |
138 | 37 | import gettext | 32 | from .DebPackage import DebPackage |
139 | 33 | |||
140 | 38 | 34 | ||
141 | 39 | def _(str): | 35 | def _(str): |
142 | 40 | return utf8(gettext.gettext(str)) | 36 | return utf8(gettext.gettext(str)) |
143 | 41 | 37 | ||
144 | 38 | |||
145 | 42 | def utf8(str): | 39 | def utf8(str): |
146 | 43 | if isinstance(str, unicode): | 40 | if isinstance(str, unicode): |
147 | 44 | return str | 41 | return str |
148 | @@ -47,6 +44,7 @@ | |||
149 | 47 | except: | 44 | except: |
150 | 48 | # assume latin1 as fallback | 45 | # assume latin1 as fallback |
151 | 49 | return unicode(str, 'latin1') | 46 | return unicode(str, 'latin1') |
152 | 47 | |||
153 | 50 | 48 | ||
154 | 51 | class GDebiCommon(object): | 49 | class GDebiCommon(object): |
155 | 52 | # cprogress may be different in child classes | 50 | # cprogress may be different in child classes |
156 | @@ -56,7 +54,7 @@ | |||
157 | 56 | self.version_info_title = "" | 54 | self.version_info_title = "" |
158 | 57 | self.version_info_msg = "" | 55 | self.version_info_msg = "" |
159 | 58 | self._deb = None | 56 | self._deb = None |
161 | 59 | self._options = options | 57 | self._options = options |
162 | 60 | self.install = [] | 58 | self.install = [] |
163 | 61 | self.remove = [] | 59 | self.remove = [] |
164 | 62 | self.unauthenticated = 0 | 60 | self.unauthenticated = 0 |
165 | @@ -71,14 +69,15 @@ | |||
166 | 71 | "To fix it run 'gksudo synaptic' or " | 69 | "To fix it run 'gksudo synaptic' or " |
167 | 72 | "'sudo apt-get install -f' " | 70 | "'sudo apt-get install -f' " |
168 | 73 | "in a terminal window.") | 71 | "in a terminal window.") |
170 | 74 | return False | 72 | return False |
171 | 75 | return True | 73 | return True |
172 | 76 | 74 | ||
173 | 77 | def open(self, file, downloaded=False): | 75 | def open(self, file, downloaded=False): |
174 | 78 | file = os.path.abspath(file) | 76 | file = os.path.abspath(file) |
175 | 79 | try: | 77 | try: |
176 | 80 | self._deb = DebPackage(file, self._cache, downloaded) | 78 | self._deb = DebPackage(file, self._cache, downloaded) |
178 | 81 | except (IOError,SystemError,ValueError),e: | 79 | except (IOError, SystemError, ValueError) as e: |
179 | 80 | logging.debug("open failed with %s" % e) | ||
180 | 82 | mimetype=guess_type(file) | 81 | mimetype=guess_type(file) |
181 | 83 | if (mimetype[0] != None and | 82 | if (mimetype[0] != None and |
182 | 84 | mimetype[0] != "application/x-debian-package"): | 83 | mimetype[0] != "application/x-debian-package"): |
183 | 85 | 84 | ||
184 | === renamed file 'GDebi/GDebi.py' => 'GDebi/GDebiGtk.py' | |||
185 | --- GDebi/GDebi.py 2012-10-11 20:09:07 +0000 | |||
186 | +++ GDebi/GDebiGtk.py 2012-10-12 16:06:23 +0000 | |||
187 | @@ -31,7 +31,7 @@ | |||
188 | 31 | import sys | 31 | import sys |
189 | 32 | import time | 32 | import time |
190 | 33 | import tempfile | 33 | import tempfile |
192 | 34 | import thread | 34 | import threading |
193 | 35 | import urllib | 35 | import urllib |
194 | 36 | 36 | ||
195 | 37 | import gi | 37 | import gi |
196 | @@ -45,12 +45,13 @@ | |||
197 | 45 | from gi.repository import Vte | 45 | from gi.repository import Vte |
198 | 46 | from gi.repository import Gio | 46 | from gi.repository import Gio |
199 | 47 | 47 | ||
200 | 48 | from DebPackage import DebPackage | ||
201 | 49 | from SimpleGtkbuilderApp import SimpleGtkbuilderApp | ||
202 | 50 | from apt.progress.base import InstallProgress | 48 | from apt.progress.base import InstallProgress |
203 | 51 | from GDebiCommon import GDebiCommon, utf8 | ||
204 | 52 | from gettext import gettext as _ | 49 | from gettext import gettext as _ |
205 | 53 | 50 | ||
206 | 51 | from .DebPackage import DebPackage | ||
207 | 52 | from .SimpleGtkbuilderApp import SimpleGtkbuilderApp | ||
208 | 53 | from .GDebiCommon import GDebiCommon, utf8 | ||
209 | 54 | |||
210 | 54 | # the timeout when the termial is expanded if no activity from dpkg | 55 | # the timeout when the termial is expanded if no activity from dpkg |
211 | 55 | # is happening | 56 | # is happening |
212 | 56 | GDEBI_TERMINAL_TIMEOUT=4*60.0 | 57 | GDEBI_TERMINAL_TIMEOUT=4*60.0 |
213 | @@ -61,27 +62,24 @@ | |||
214 | 61 | try: | 62 | try: |
215 | 62 | import lsb_release | 63 | import lsb_release |
216 | 63 | UBUNTU = lsb_release.get_distro_information()['ID'] == 'Ubuntu' | 64 | UBUNTU = lsb_release.get_distro_information()['ID'] == 'Ubuntu' |
218 | 64 | except Exception, e: | 65 | except Exception as e: |
219 | 65 | pass | 66 | pass |
220 | 66 | 67 | ||
222 | 67 | class GDebi(SimpleGtkbuilderApp, GDebiCommon): | 68 | class GDebiGtk(SimpleGtkbuilderApp, GDebiCommon): |
223 | 68 | 69 | ||
224 | 69 | def __init__(self, datadir, options, file=""): | 70 | def __init__(self, datadir, options, file=""): |
225 | 70 | GDebiCommon.__init__(self,datadir,options,file) | 71 | GDebiCommon.__init__(self,datadir,options,file) |
226 | 71 | localesApp="gdebi" | ||
227 | 72 | localesDir="/usr/share/locale" | ||
228 | 73 | |||
229 | 74 | SimpleGtkbuilderApp.__init__( | 72 | SimpleGtkbuilderApp.__init__( |
231 | 75 | self, path=datadir+"/gdebi.ui", domain="gdebi") | 73 | self, path=os.path.join(datadir, "gdebi.ui"), domain="gdebi") |
232 | 74 | |||
233 | 76 | # use a nicer default icon | 75 | # use a nicer default icon |
234 | 77 | icons = Gtk.IconTheme.get_default() | 76 | icons = Gtk.IconTheme.get_default() |
235 | 78 | try: | 77 | try: |
236 | 79 | logo=icons.load_icon("gnome-mime-application-x-deb", 48, 0) | 78 | logo=icons.load_icon("gnome-mime-application-x-deb", 48, 0) |
237 | 80 | if logo != "": | 79 | if logo != "": |
238 | 81 | Gtk.Window.set_default_icon_list([logo]) | 80 | Gtk.Window.set_default_icon_list([logo]) |
242 | 82 | except Exception, e: | 81 | except Exception as e: |
243 | 83 | print "Error loading logo" | 82 | logging.warn("Error loading logo %s" % e) |
241 | 84 | pass | ||
244 | 85 | 83 | ||
245 | 86 | # create terminal | 84 | # create terminal |
246 | 87 | self.vte_terminal = Vte.Terminal() | 85 | self.vte_terminal = Vte.Terminal() |
247 | @@ -193,7 +191,7 @@ | |||
248 | 193 | self.gio_progress_callback, 0): | 191 | self.gio_progress_callback, 0): |
249 | 194 | file = gio_dest.get_path() | 192 | file = gio_dest.get_path() |
250 | 195 | self.dialog_gio_download.hide() | 193 | self.dialog_gio_download.hide() |
252 | 196 | except Exception, e: | 194 | except Exception as e: |
253 | 197 | self.show_alert(Gtk.MessageType.ERROR, | 195 | self.show_alert(Gtk.MessageType.ERROR, |
254 | 198 | _("Download failed"), | 196 | _("Download failed"), |
255 | 199 | _("Downloading the package failed: " | 197 | _("Downloading the package failed: " |
256 | @@ -255,7 +253,7 @@ | |||
257 | 255 | buf = self.textview_description.get_buffer() | 253 | buf = self.textview_description.get_buffer() |
258 | 256 | try: | 254 | try: |
259 | 257 | long_desc = "" | 255 | long_desc = "" |
261 | 258 | raw_desc = string.split(utf8(self._deb["Description"]), "\n") | 256 | raw_desc = utf8(self._deb["Description"]).split("\n") |
262 | 259 | # append a newline to the summary in the first line | 257 | # append a newline to the summary in the first line |
263 | 260 | summary = raw_desc[0] | 258 | summary = raw_desc[0] |
264 | 261 | raw_desc[0] = "" | 259 | raw_desc[0] = "" |
265 | @@ -306,8 +304,8 @@ | |||
266 | 306 | header = store.append(None, [_("Upstream data")]) | 304 | header = store.append(None, [_("Upstream data")]) |
267 | 307 | for name in self._deb.filelist: | 305 | for name in self._deb.filelist: |
268 | 308 | store.append(header, [name]) | 306 | store.append(header, [name]) |
271 | 309 | except Exception, e: | 307 | except Exception as e: |
272 | 310 | print "Exception while reading the filelist: '%s'" % e | 308 | logging.exception("Exception while reading the filelist: '%s'" % e) |
273 | 311 | store.clear() | 309 | store.clear() |
274 | 312 | store.append(None, [_("Error reading filelist")]) | 310 | store.append(None, [_("Error reading filelist")]) |
275 | 313 | self.treeview_files.set_model(store) | 311 | self.treeview_files.set_model(store) |
276 | @@ -324,7 +322,7 @@ | |||
277 | 324 | #glib.markup_escape_text(self._deb._failure_string) + | 322 | #glib.markup_escape_text(self._deb._failure_string) + |
278 | 325 | self._deb._failure_string + | 323 | self._deb._failure_string + |
279 | 326 | "</span>") | 324 | "</span>") |
281 | 327 | self.button_install.set_label(_("_Install Package")) | 325 | self.button_install.set_label(_("_Install Package")) |
282 | 328 | 326 | ||
283 | 329 | self.button_install.set_sensitive(False) | 327 | self.button_install.set_sensitive(False) |
284 | 330 | self.button_details.hide() | 328 | self.button_details.hide() |
285 | @@ -404,12 +402,12 @@ | |||
286 | 404 | elif parent_path == 0: | 402 | elif parent_path == 0: |
287 | 405 | try: | 403 | try: |
288 | 406 | data = self._deb.control_content(name) | 404 | data = self._deb.control_content(name) |
290 | 407 | except Exception, e: | 405 | except Exception as e: |
291 | 408 | data = _("Error reading file content '%s'") % e | 406 | data = _("Error reading file content '%s'") % e |
292 | 409 | elif parent_path == 1: | 407 | elif parent_path == 1: |
293 | 410 | try: | 408 | try: |
294 | 411 | data = self._deb.data_content(name) | 409 | data = self._deb.data_content(name) |
296 | 412 | except Exception, e: | 410 | except Exception as e: |
297 | 413 | data = _("Error reading file content '%s'") % e | 411 | data = _("Error reading file content '%s'") % e |
298 | 414 | else: | 412 | else: |
299 | 415 | assert False, "NOT REACHED" | 413 | assert False, "NOT REACHED" |
300 | @@ -477,7 +475,7 @@ | |||
301 | 477 | 475 | ||
302 | 478 | def on_about_activate(self, widget): | 476 | def on_about_activate(self, widget): |
303 | 479 | #print "about" | 477 | #print "about" |
305 | 480 | from Version import VERSION | 478 | from .Version import VERSION |
306 | 481 | self.dialog_about.set_version(VERSION) | 479 | self.dialog_about.set_version(VERSION) |
307 | 482 | self.dialog_about.run() | 480 | self.dialog_about.run() |
308 | 483 | self.dialog_about.hide() | 481 | self.dialog_about.hide() |
309 | @@ -620,16 +618,16 @@ | |||
310 | 620 | self.vte_terminal, | 618 | self.vte_terminal, |
311 | 621 | self.label_action, | 619 | self.label_action, |
312 | 622 | self.expander_install) | 620 | self.expander_install) |
314 | 623 | errMsg = None | 621 | #errMsg = None |
315 | 624 | try: | 622 | try: |
316 | 625 | res = self._cache.commit(fprogress,iprogress) | 623 | res = self._cache.commit(fprogress,iprogress) |
318 | 626 | except IOError, msg: | 624 | except IOError as msg: |
319 | 627 | res = False | 625 | res = False |
321 | 628 | errMsg = "%s" % msg | 626 | #errMsg = "%s" % msg |
322 | 629 | header = _("Could not download all required files") | 627 | header = _("Could not download all required files") |
323 | 630 | body = _("Please check your internet connection or " | 628 | body = _("Please check your internet connection or " |
324 | 631 | "installation medium.") | 629 | "installation medium.") |
326 | 632 | except SystemError, msg: | 630 | except SystemError as msg: |
327 | 633 | res = False | 631 | res = False |
328 | 634 | header = _("Could not install all dependencies"), | 632 | header = _("Could not install all dependencies"), |
329 | 635 | body = _("Usually this is related to an error of the " | 633 | body = _("Usually this is related to an error of the " |
330 | @@ -817,7 +815,7 @@ | |||
331 | 817 | logging.exception("lock.release failed") | 815 | logging.exception("lock.release failed") |
332 | 818 | 816 | ||
333 | 819 | # get a lock | 817 | # get a lock |
335 | 820 | lock = thread.allocate_lock() | 818 | lock = threading.Lock() |
336 | 821 | lock.acquire() | 819 | lock.acquire() |
337 | 822 | 820 | ||
338 | 823 | # ui | 821 | # ui |
339 | @@ -872,17 +870,17 @@ | |||
340 | 872 | while True: | 870 | while True: |
341 | 873 | try: | 871 | try: |
342 | 874 | read += os.read(readfd,1) | 872 | read += os.read(readfd,1) |
344 | 875 | except OSError, (errno,errstr): | 873 | except OSError as e: |
345 | 876 | # resource temporarly unavailable is ignored | 874 | # resource temporarly unavailable is ignored |
346 | 877 | from errno import EAGAIN | 875 | from errno import EAGAIN |
349 | 878 | if errno != EAGAIN: | 876 | if e.errno != EAGAIN: |
350 | 879 | print errstr | 877 | logging.warn(e.errstr) |
351 | 880 | break | 878 | break |
352 | 881 | self.time_last_update = time.time() | 879 | self.time_last_update = time.time() |
353 | 882 | if read.endswith("\n"): | 880 | if read.endswith("\n"): |
355 | 883 | statusl = string.split(read, ":") | 881 | statusl = read.split(":") |
356 | 884 | if len(statusl) < 3: | 882 | if len(statusl) < 3: |
358 | 885 | print "got garbage from dpkg: '%s'" % read | 883 | logging.warn("got garbage from dpkg: '%s'" % read) |
359 | 886 | read = "" | 884 | read = "" |
360 | 887 | break | 885 | break |
361 | 888 | status = statusl[2].strip() | 886 | status = statusl[2].strip() |
362 | @@ -968,19 +966,19 @@ | |||
363 | 968 | 966 | ||
364 | 969 | class FetchProgressAdapter(apt.progress.base.AcquireProgress): | 967 | class FetchProgressAdapter(apt.progress.base.AcquireProgress): |
365 | 970 | def __init__(self,progress,action,main): | 968 | def __init__(self,progress,action,main): |
367 | 971 | super(GDebi.FetchProgressAdapter, self).__init__() | 969 | super(GDebiGtk.FetchProgressAdapter, self).__init__() |
368 | 972 | self.progress = progress | 970 | self.progress = progress |
369 | 973 | self.action = action | 971 | self.action = action |
370 | 974 | self.main = main | 972 | self.main = main |
371 | 975 | def start(self): | 973 | def start(self): |
373 | 976 | super(GDebi.FetchProgressAdapter, self).start() | 974 | super(GDebiGtk.FetchProgressAdapter, self).start() |
374 | 977 | self.action.set_markup("<i>"+_("Downloading additional package files...")+"</i>") | 975 | self.action.set_markup("<i>"+_("Downloading additional package files...")+"</i>") |
375 | 978 | self.progress.set_fraction(0) | 976 | self.progress.set_fraction(0) |
376 | 979 | def stop(self): | 977 | def stop(self): |
377 | 980 | #print "stop()" | 978 | #print "stop()" |
378 | 981 | pass | 979 | pass |
379 | 982 | def pulse(self, owner): | 980 | def pulse(self, owner): |
381 | 983 | super(GDebi.FetchProgressAdapter, self).pulse(owner) | 981 | super(GDebiGtk.FetchProgressAdapter, self).pulse(owner) |
382 | 984 | at_item = min(self.current_items + 1, self.total_items) | 982 | at_item = min(self.current_items + 1, self.total_items) |
383 | 985 | if self.current_cps > 0: | 983 | if self.current_cps > 0: |
384 | 986 | self.progress.set_text(_("File %s of %s at %sB/s") % (at_item,self.total_items,apt_pkg.size_to_str(self.current_cps))) | 984 | self.progress.set_text(_("File %s of %s at %sB/s") % (at_item,self.total_items,apt_pkg.size_to_str(self.current_cps))) |
385 | @@ -1017,18 +1015,19 @@ | |||
386 | 1017 | Gtk.main_iteration() | 1015 | Gtk.main_iteration() |
387 | 1018 | def done(self): | 1016 | def done(self): |
388 | 1019 | self.progressbar.hide() | 1017 | self.progressbar.hide() |
390 | 1020 | 1018 | ||
391 | 1019 | |||
392 | 1021 | if __name__ == "__main__": | 1020 | if __name__ == "__main__": |
394 | 1022 | app = GDebi("data/",None) | 1021 | app = GDebiGtk("data/",None) |
395 | 1023 | 1022 | ||
396 | 1024 | pkgs = ["cw"] | 1023 | pkgs = ["cw"] |
397 | 1025 | for pkg in pkgs: | 1024 | for pkg in pkgs: |
399 | 1026 | print "installing %s" % pkg | 1025 | print("installing %s" % pkg) |
400 | 1027 | app._cache[pkg].mark_install() | 1026 | app._cache[pkg].mark_install() |
401 | 1028 | 1027 | ||
402 | 1029 | for pkg in app._cache: | 1028 | for pkg in app._cache: |
403 | 1030 | if pkg.marked_install or pkg.marked_upgrade: | 1029 | if pkg.marked_install or pkg.marked_upgrade: |
405 | 1031 | print pkg.name | 1030 | print(pkg.name) |
406 | 1032 | 1031 | ||
407 | 1033 | apt_pkg.pkgsystem_lock() | 1032 | apt_pkg.pkgsystem_lock() |
408 | 1034 | app.dialog_deb_install.set_transient_for(app.window_main) | 1033 | app.dialog_deb_install.set_transient_for(app.window_main) |
409 | @@ -1043,6 +1042,6 @@ | |||
410 | 1043 | app.label_action, | 1042 | app.label_action, |
411 | 1044 | app.expander_install) | 1043 | app.expander_install) |
412 | 1045 | res = app._cache.commit(fprogress,iprogress) | 1044 | res = app._cache.commit(fprogress,iprogress) |
414 | 1046 | print "commit retured: %s" % res | 1045 | print("commit retured: %s" % res) |
415 | 1047 | 1046 | ||
416 | 1048 | Gtk.main() | 1047 | Gtk.main() |
417 | 1049 | 1048 | ||
418 | === modified file 'GDebi/GDebiKDE.py' | |||
419 | --- GDebi/GDebiKDE.py 2012-09-13 20:50:23 +0000 | |||
420 | +++ GDebi/GDebiKDE.py 2012-10-12 16:06:23 +0000 | |||
421 | @@ -22,27 +22,47 @@ | |||
422 | 22 | # You should have received a copy of the GNU General Public License | 22 | # You should have received a copy of the GNU General Public License |
423 | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
424 | 24 | 24 | ||
425 | 25 | import logging | ||
426 | 25 | import os | 26 | import os |
428 | 26 | import subprocess | 27 | import re |
429 | 27 | import string | 28 | import string |
440 | 28 | import re | 29 | import sys |
441 | 29 | import pty | 30 | |
442 | 30 | import warnings | 31 | |
443 | 31 | warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning) | 32 | from PyKDE4.kdeui import ( |
444 | 32 | import apt_pkg | 33 | KApplication, |
445 | 33 | 34 | KIcon, | |
446 | 34 | from PyKDE4.kdecore import * | 35 | KMessageBox, |
447 | 35 | from PyKDE4.kdeui import * | 36 | DesktopIcon, |
448 | 36 | from PyQt4.QtCore import * | 37 | ) |
449 | 37 | from PyQt4.QtGui import * | 38 | from PyQt4.QtCore import ( |
450 | 39 | Qt, | ||
451 | 40 | SIGNAL, | ||
452 | 41 | QStringList, | ||
453 | 42 | QTimer, | ||
454 | 43 | ) | ||
455 | 44 | from PyQt4.QtGui import ( | ||
456 | 45 | QDialog, | ||
457 | 46 | QHBoxLayout, | ||
458 | 47 | QTextCursor, | ||
459 | 48 | QTextEdit, | ||
460 | 49 | QTextOption, | ||
461 | 50 | ) | ||
462 | 38 | from PyQt4 import uic | 51 | from PyQt4 import uic |
463 | 39 | 52 | ||
464 | 40 | from apt.cache import Cache | 53 | from apt.cache import Cache |
465 | 41 | from DebPackage import DebPackage | ||
466 | 42 | 54 | ||
467 | 43 | import gettext | 55 | import gettext |
470 | 44 | from GDebiCommon import GDebiCommon, utf8, _ | 56 | |
471 | 45 | from KDEAptDialogs import * | 57 | from .DebPackage import DebPackage |
472 | 58 | from .GDebiCommon import GDebiCommon, utf8, _ | ||
473 | 59 | from .KDEAptDialogs import ( | ||
474 | 60 | CacheProgressAdapter, | ||
475 | 61 | KDEDpkgInstallProgress, | ||
476 | 62 | KDEFetchProgressAdapter, | ||
477 | 63 | KDEInstallProgressAdapter, | ||
478 | 64 | ) | ||
479 | 65 | |||
480 | 46 | 66 | ||
481 | 47 | def __(catalog,str): | 67 | def __(catalog,str): |
482 | 48 | return unicode(gettext.dgettext(catalog, str), 'UTF-8') | 68 | return unicode(gettext.dgettext(catalog, str), 'UTF-8') |
483 | @@ -109,19 +129,23 @@ | |||
484 | 109 | return | 129 | return |
485 | 110 | # block signals so that we do not run into a recursion | 130 | # block signals so that we do not run into a recursion |
486 | 111 | self._block = True | 131 | self._block = True |
489 | 112 | para = self.paragraphs() - 1 | 132 | #para = self.paragraphs() - 1 |
490 | 113 | pos = self.paragraphLength(para) | 133 | #pos = self.paragraphLength(para) |
491 | 114 | self.moveCursor(QTextCursor.End) | 134 | self.moveCursor(QTextCursor.End) |
492 | 115 | self._block = False | 135 | self._block = False |
493 | 116 | 136 | ||
494 | 137 | |||
495 | 117 | class GDebiKDEDialog(QDialog): | 138 | class GDebiKDEDialog(QDialog): |
496 | 118 | """Our main user interface, load from UI file""" | 139 | """Our main user interface, load from UI file""" |
497 | 119 | def __init__(self, parent): | 140 | def __init__(self, parent): |
498 | 120 | QDialog.__init__(self, parent) | 141 | QDialog.__init__(self, parent) |
499 | 121 | loadUi("GDebiKDEDialog.ui", self) | 142 | loadUi("GDebiKDEDialog.ui", self) |
500 | 122 | 143 | ||
501 | 144 | |||
502 | 123 | class GDebiKDE(GDebiCommon, GDebiKDEDialog): | 145 | class GDebiKDE(GDebiCommon, GDebiKDEDialog): |
504 | 124 | def __init__(self,datadir,options,file="",parent = None,name = None,modal = 0,fl = 0): | 146 | |
505 | 147 | def __init__(self, datadir, options, file="", parent=None, name=None, | ||
506 | 148 | modal=0, fl=0): | ||
507 | 125 | GDebiKDEDialog.__init__(self,parent) | 149 | GDebiKDEDialog.__init__(self,parent) |
508 | 126 | GDebiCommon.__init__(self,datadir,options,file) | 150 | GDebiCommon.__init__(self,datadir,options,file) |
509 | 127 | # load the icon | 151 | # load the icon |
510 | @@ -291,9 +315,10 @@ | |||
511 | 291 | for r in remove: | 315 | for r in remove: |
512 | 292 | changedList.append(_("To be removed: %s") % r) | 316 | changedList.append(_("To be removed: %s") % r) |
513 | 293 | 317 | ||
517 | 294 | infoReport = KMessageBox.informationList(self, | 318 | KMessageBox.informationList( |
518 | 295 | _("<b>To install the following changes are required:</b>"), | 319 | self, |
519 | 296 | changedList, _("Details")) | 320 | _("<b>To install the following changes are required:</b>"), |
520 | 321 | changedList, _("Details")) | ||
521 | 297 | 322 | ||
522 | 298 | def installButtonClicked(self): | 323 | def installButtonClicked(self): |
523 | 299 | # if not root, start a new instance | 324 | # if not root, start a new instance |
524 | @@ -336,16 +361,17 @@ | |||
525 | 336 | self.installDialog.installingLabel, | 361 | self.installDialog.installingLabel, |
526 | 337 | self.installDialog) | 362 | self.installDialog) |
527 | 338 | self.installDialog.konsole.setInstallProgress(iprogress) | 363 | self.installDialog.konsole.setInstallProgress(iprogress) |
529 | 339 | errMsg = None | 364 | #errMsg = None |
530 | 340 | try: | 365 | try: |
531 | 341 | res = self._cache.commit(fprogress,iprogress) | 366 | res = self._cache.commit(fprogress,iprogress) |
533 | 342 | except IOError, msg: | 367 | except IOError as msg: |
534 | 343 | res = False | 368 | res = False |
536 | 344 | errMsg = "%s" % msg | 369 | #errMsg = "%s" % msg |
537 | 345 | header = _("Could not download all required files") | 370 | header = _("Could not download all required files") |
538 | 346 | body = _("Please check your internet connection or " | 371 | body = _("Please check your internet connection or " |
539 | 347 | "installation medium.") | 372 | "installation medium.") |
541 | 348 | except SystemError, msg: | 373 | except SystemError as msg: |
542 | 374 | logging.warn("error: %s" % msg) | ||
543 | 349 | res = False | 375 | res = False |
544 | 350 | header = _("Could not install all dependencies") | 376 | header = _("Could not install all dependencies") |
545 | 351 | body = _("Usually this is related to an error of the " | 377 | body = _("Usually this is related to an error of the " |
546 | 352 | 378 | ||
547 | === modified file 'GDebi/KDEAptDialogs.py' | |||
548 | --- GDebi/KDEAptDialogs.py 2011-08-16 08:05:17 +0000 | |||
549 | +++ GDebi/KDEAptDialogs.py 2012-10-12 16:06:23 +0000 | |||
550 | @@ -22,31 +22,28 @@ | |||
551 | 22 | # You should have received a copy of the GNU General Public License | 22 | # You should have received a copy of the GNU General Public License |
552 | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
553 | 24 | 24 | ||
555 | 25 | import sys | 25 | import logging |
556 | 26 | import os | 26 | import os |
557 | 27 | import subprocess | 27 | import subprocess |
559 | 28 | import string | 28 | |
560 | 29 | import apt | 29 | import apt |
561 | 30 | import apt_pkg | 30 | import apt_pkg |
573 | 31 | from PyKDE4.kdecore import * | 31 | |
574 | 32 | from PyKDE4.kdeui import * | 32 | from PyKDE4.kdeui import ( |
575 | 33 | from PyQt4.QtCore import * | 33 | KApplication, |
576 | 34 | from PyQt4.QtGui import * | 34 | KMessageBox, |
577 | 35 | 35 | KStandardGuiItem, | |
578 | 36 | import urllib | 36 | ) |
579 | 37 | import fcntl | 37 | from PyQt4.QtCore import ( |
580 | 38 | import posix | 38 | QTimer, |
581 | 39 | import time | 39 | ) |
582 | 40 | import thread | 40 | |
572 | 41 | import re | ||
583 | 42 | import pty | 41 | import pty |
584 | 43 | import select | 42 | import select |
585 | 44 | 43 | ||
586 | 45 | from apt.cache import Cache | ||
587 | 46 | from apt.debfile import DebPackage | ||
588 | 47 | from apt.progress.base import InstallProgress | 44 | from apt.progress.base import InstallProgress |
591 | 48 | from gettext import gettext as gett | 45 | |
592 | 49 | from GDebiCommon import utf8, _ | 46 | from .GDebiCommon import utf8, _ |
593 | 50 | 47 | ||
594 | 51 | 48 | ||
595 | 52 | class KDEDpkgInstallProgress(object): | 49 | class KDEDpkgInstallProgress(object): |
596 | @@ -66,7 +63,7 @@ | |||
597 | 66 | self.progress.setValue(0) | 63 | self.progress.setValue(0) |
598 | 67 | 64 | ||
599 | 68 | def timeoutHandler(self,signum, frame): | 65 | def timeoutHandler(self,signum, frame): |
601 | 69 | raise IOError, "Stopped waiting for I/O." | 66 | raise IOError("Stopped waiting for I/O.") |
602 | 70 | 67 | ||
603 | 71 | def commit(self): | 68 | def commit(self): |
604 | 72 | # ui | 69 | # ui |
605 | @@ -78,7 +75,7 @@ | |||
606 | 78 | 75 | ||
607 | 79 | if self.child_pid == 0: | 76 | if self.child_pid == 0: |
608 | 80 | os.environ["TERM"] = "dumb" | 77 | os.environ["TERM"] = "dumb" |
610 | 81 | if not os.environ.has_key("DEBIAN_FRONTEND"): | 78 | if not "DEBIAN_FRONTEND" in os.environ: |
611 | 82 | os.environ["DEBIAN_FRONTEND"] = "noninteractive" | 79 | os.environ["DEBIAN_FRONTEND"] = "noninteractive" |
612 | 83 | os.environ["APT_LISTCHANGES_FRONTEND"] = "none" | 80 | os.environ["APT_LISTCHANGES_FRONTEND"] = "none" |
613 | 84 | exitstatus = subprocess.call(argv) | 81 | exitstatus = subprocess.call(argv) |
614 | @@ -91,7 +88,7 @@ | |||
615 | 91 | if len(rlist) > 0: | 88 | if len(rlist) > 0: |
616 | 92 | line = os.read(self.master_fd, 255) | 89 | line = os.read(self.master_fd, 255) |
617 | 93 | self.parent.konsole.insertWithTermCodes(utf8(line)) | 90 | self.parent.konsole.insertWithTermCodes(utf8(line)) |
619 | 94 | except Exception, e: | 91 | except Exception as e: |
620 | 95 | #print e | 92 | #print e |
621 | 96 | from errno import EAGAIN | 93 | from errno import EAGAIN |
622 | 97 | if hasattr(e, "errno") and e.errno == EAGAIN: | 94 | if hasattr(e, "errno") and e.errno == EAGAIN: |
623 | @@ -150,7 +147,7 @@ | |||
624 | 150 | # run the base class | 147 | # run the base class |
625 | 151 | try: | 148 | try: |
626 | 152 | InstallProgress.updateInterface(self) | 149 | InstallProgress.updateInterface(self) |
628 | 153 | except ValueError,e: | 150 | except ValueError as e: |
629 | 154 | pass | 151 | pass |
630 | 155 | # log the output of dpkg (on the master_fd) to the DumbTerminal | 152 | # log the output of dpkg (on the master_fd) to the DumbTerminal |
631 | 156 | while True: | 153 | while True: |
632 | @@ -163,8 +160,8 @@ | |||
633 | 163 | else: | 160 | else: |
634 | 164 | # nothing happend within the timeout, break | 161 | # nothing happend within the timeout, break |
635 | 165 | break | 162 | break |
638 | 166 | except Exception, e: | 163 | except Exception as e: |
639 | 167 | #print "updateInterface: ", e | 164 | logging.debug("updateInterface: " % e) |
640 | 168 | break | 165 | break |
641 | 169 | KApplication.kApplication().processEvents() | 166 | KApplication.kApplication().processEvents() |
642 | 170 | 167 | ||
643 | @@ -173,7 +170,7 @@ | |||
644 | 173 | (self.child_pid, self.master_fd) = pty.fork() | 170 | (self.child_pid, self.master_fd) = pty.fork() |
645 | 174 | if self.child_pid == 0: | 171 | if self.child_pid == 0: |
646 | 175 | os.environ["TERM"] = "dumb" | 172 | os.environ["TERM"] = "dumb" |
648 | 176 | if not os.environ.has_key("DEBIAN_FRONTEND"): | 173 | if not "DEBIAN_FRONTEND" in os.environ: |
649 | 177 | os.environ["DEBIAN_FRONTEND"] = "noninteractive" | 174 | os.environ["DEBIAN_FRONTEND"] = "noninteractive" |
650 | 178 | os.environ["APT_LISTCHANGES_FRONTEND"] = "none" | 175 | os.environ["APT_LISTCHANGES_FRONTEND"] = "none" |
651 | 179 | return self.child_pid | 176 | return self.child_pid |
652 | @@ -182,8 +179,8 @@ | |||
653 | 182 | while True: | 179 | while True: |
654 | 183 | try: | 180 | try: |
655 | 184 | select.select([self.statusfd],[],[], self.select_timeout) | 181 | select.select([self.statusfd],[],[], self.select_timeout) |
658 | 185 | except Exception, e: | 182 | except Exception as e: |
659 | 186 | #print "waitChild: ", e | 183 | logging.debug("waitChild: " % e) |
660 | 187 | pass | 184 | pass |
661 | 188 | self.updateInterface() | 185 | self.updateInterface() |
662 | 189 | (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) | 186 | (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) |
663 | 190 | 187 | ||
664 | === modified file 'GDebi/SimpleGtkbuilderApp.py' | |||
665 | --- GDebi/SimpleGtkbuilderApp.py 2011-05-25 16:22:00 +0000 | |||
666 | +++ GDebi/SimpleGtkbuilderApp.py 2012-10-12 16:06:23 +0000 | |||
667 | @@ -20,9 +20,6 @@ | |||
668 | 20 | # USA | 20 | # USA |
669 | 21 | 21 | ||
670 | 22 | import logging | 22 | import logging |
671 | 23 | import os | ||
672 | 24 | import sys | ||
673 | 25 | import re | ||
674 | 26 | 23 | ||
675 | 27 | from gi.repository import Gtk | 24 | from gi.repository import Gtk |
676 | 28 | 25 | ||
677 | 29 | 26 | ||
678 | === modified file 'debian/control' | |||
679 | --- debian/control 2012-09-12 21:17:04 +0000 | |||
680 | +++ debian/control 2012-10-12 16:06:23 +0000 | |||
681 | @@ -6,6 +6,7 @@ | |||
682 | 6 | Michael Vogt <mvo@debian.org> | 6 | Michael Vogt <mvo@debian.org> |
683 | 7 | Build-Depends: debhelper (>= 8), | 7 | Build-Depends: debhelper (>= 8), |
684 | 8 | python (>= 2.6.6-3~), | 8 | python (>= 2.6.6-3~), |
685 | 9 | python-setuptools, | ||
686 | 9 | intltool | 10 | intltool |
687 | 10 | X-Python-Version: >= 2.6 | 11 | X-Python-Version: >= 2.6 |
688 | 11 | Standards-Version: 3.9.3 | 12 | Standards-Version: 3.9.3 |
689 | 12 | 13 | ||
690 | === modified file 'gdebi' | |||
691 | --- gdebi 2012-09-13 09:44:20 +0000 | |||
692 | +++ gdebi 2012-10-12 16:06:23 +0000 | |||
693 | @@ -78,7 +78,7 @@ | |||
694 | 78 | 78 | ||
695 | 79 | try: | 79 | try: |
696 | 80 | debi = GDebiCli(options) | 80 | debi = GDebiCli(options) |
698 | 81 | except SystemError, e: | 81 | except SystemError as e: |
699 | 82 | print "Error opening the cache:\n%s" % e | 82 | print "Error opening the cache:\n%s" % e |
700 | 83 | sys.exit(1) | 83 | sys.exit(1) |
701 | 84 | if not debi.open(args[0]): | 84 | if not debi.open(args[0]): |
702 | 85 | 85 | ||
703 | === modified file 'gdebi-gtk' | |||
704 | --- gdebi-gtk 2012-09-12 22:03:35 +0000 | |||
705 | +++ gdebi-gtk 2012-10-12 16:06:23 +0000 | |||
706 | @@ -28,7 +28,7 @@ | |||
707 | 28 | 28 | ||
708 | 29 | 29 | ||
709 | 30 | from optparse import OptionParser | 30 | from optparse import OptionParser |
711 | 31 | from GDebi.GDebi import GDebi | 31 | from GDebi.GDebiGtk import GDebiGtk |
712 | 32 | 32 | ||
713 | 33 | from gettext import gettext as _ | 33 | from gettext import gettext as _ |
714 | 34 | import gettext | 34 | import gettext |
715 | @@ -64,7 +64,7 @@ | |||
716 | 64 | 64 | ||
717 | 65 | try: | 65 | try: |
718 | 66 | Gtk.init_check(sys.argv) | 66 | Gtk.init_check(sys.argv) |
720 | 67 | except RuntimeError, e: | 67 | except RuntimeError as e: |
721 | 68 | sys.stderr.write("Can not start %s: %s. Exiting\n" % (sys.argv[0], e)) | 68 | sys.stderr.write("Can not start %s: %s. Exiting\n" % (sys.argv[0], e)) |
722 | 69 | sys.exit(1) | 69 | sys.exit(1) |
723 | 70 | 70 | ||
724 | @@ -73,8 +73,8 @@ | |||
725 | 73 | afile = args[0] | 73 | afile = args[0] |
726 | 74 | 74 | ||
727 | 75 | try: | 75 | try: |
730 | 76 | app = GDebi(datadir=data,options=options,file=afile) | 76 | app = GDebiGtk(datadir=data,options=options,file=afile) |
731 | 77 | except SystemError, e: | 77 | except SystemError as e: |
732 | 78 | err_header = _("Software index is broken") | 78 | err_header = _("Software index is broken") |
733 | 79 | err_body = _("This is a major failure of your software " | 79 | err_body = _("This is a major failure of your software " |
734 | 80 | "management system. Please check for broken packages " | 80 | "management system. Please check for broken packages " |
735 | 81 | 81 | ||
736 | === modified file 'gdebi-kde' | |||
737 | --- gdebi-kde 2012-09-12 22:03:35 +0000 | |||
738 | +++ gdebi-kde 2012-10-12 16:06:23 +0000 | |||
739 | @@ -103,7 +103,7 @@ | |||
740 | 103 | if options.non_interactive == True: | 103 | if options.non_interactive == True: |
741 | 104 | gdebi.installButtonClicked() | 104 | gdebi.installButtonClicked() |
742 | 105 | app.exec_() | 105 | app.exec_() |
744 | 106 | except SystemError, e: | 106 | except SystemError as e: |
745 | 107 | err_header = _("Software index is broken") | 107 | err_header = _("Software index is broken") |
746 | 108 | err_body = _("This is a major failure of your software " | 108 | err_body = _("This is a major failure of your software " |
747 | 109 | "management system. Please check for broken packages " | 109 | "management system. Please check for broken packages " |
748 | 110 | 110 | ||
749 | === modified file 'po/POTFILES.in' | |||
750 | --- po/POTFILES.in 2010-07-02 14:52:39 +0000 | |||
751 | +++ po/POTFILES.in 2012-10-12 16:06:23 +0000 | |||
752 | @@ -6,7 +6,7 @@ | |||
753 | 6 | data/gdebi.desktop.in | 6 | data/gdebi.desktop.in |
754 | 7 | gdebi-gtk | 7 | gdebi-gtk |
755 | 8 | GDebi/DebPackage.py | 8 | GDebi/DebPackage.py |
757 | 9 | GDebi/GDebi.py | 9 | GDebi/GDebiGtk.py |
758 | 10 | GDebi/GDebiCli.py | 10 | GDebi/GDebiCli.py |
759 | 11 | GDebi/GDebiKDE.py | 11 | GDebi/GDebiKDE.py |
760 | 12 | GDebi/GDebiCommon.py | 12 | GDebi/GDebiCommon.py |
761 | 13 | 13 | ||
762 | === modified file 'setup.py' | |||
763 | --- setup.py 2011-08-28 14:22:30 +0000 | |||
764 | +++ setup.py 2012-10-12 16:06:23 +0000 | |||
765 | @@ -1,7 +1,7 @@ | |||
766 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
767 | 2 | 2 | ||
768 | 3 | import os | 3 | import os |
770 | 4 | from distutils.core import setup | 4 | from setuptools import setup |
771 | 5 | from glob import glob | 5 | from glob import glob |
772 | 6 | from re import compile | 6 | from re import compile |
773 | 7 | 7 | ||
774 | @@ -26,6 +26,7 @@ | |||
775 | 26 | 26 | ||
776 | 27 | s = setup(name='gdebi', | 27 | s = setup(name='gdebi', |
777 | 28 | version=version, | 28 | version=version, |
778 | 29 | test_suite="tests", | ||
779 | 29 | packages=['GDebi'], | 30 | packages=['GDebi'], |
780 | 30 | scripts=['gdebi', 'gdebi-gtk', 'gdebi-kde'], | 31 | scripts=['gdebi', 'gdebi-gtk', 'gdebi-kde'], |
781 | 31 | data_files=[('share/gdebi/', | 32 | data_files=[('share/gdebi/', |
782 | 32 | 33 | ||
783 | === added file 'tests/__init__.py' | |||
784 | === added file 'tests/test_gdebi_cli.py' | |||
785 | --- tests/test_gdebi_cli.py 1970-01-01 00:00:00 +0000 | |||
786 | +++ tests/test_gdebi_cli.py 2012-10-12 16:06:23 +0000 | |||
787 | @@ -0,0 +1,42 @@ | |||
788 | 1 | #!/usr/bin/python | ||
789 | 2 | |||
790 | 3 | import os | ||
791 | 4 | import unittest | ||
792 | 5 | |||
793 | 6 | from mock import Mock | ||
794 | 7 | |||
795 | 8 | from GDebi.GDebiCli import GDebiCli | ||
796 | 9 | |||
797 | 10 | |||
798 | 11 | class GDebiCliTestCase(unittest.TestCase): | ||
799 | 12 | |||
800 | 13 | @classmethod | ||
801 | 14 | def setUpClass(cls): | ||
802 | 15 | # use classmethod to speed up the tests as the cache is only | ||
803 | 16 | # read once | ||
804 | 17 | cls.testdir = os.path.join(os.path.dirname(__file__)) | ||
805 | 18 | mock_options = Mock() | ||
806 | 19 | mock_options.rootdir = None | ||
807 | 20 | mock_options.apt_opts = [] | ||
808 | 21 | cls.cli = GDebiCli(options=mock_options) | ||
809 | 22 | |||
810 | 23 | def test_against_deb_with_conflict_against_apt(self): | ||
811 | 24 | res = self.cli.open(os.path.join(self.testdir, "gdebi-test1.deb")) | ||
812 | 25 | self.assertFalse(res) | ||
813 | 26 | self.assertEqual( | ||
814 | 27 | self.cli._deb._failure_string, | ||
815 | 28 | "Conflicts with the installed package 'apt'") | ||
816 | 29 | |||
817 | 30 | def test_against_impossible_dep(self): | ||
818 | 31 | res = self.cli.open(os.path.join(self.testdir, "gdebi-test2.deb")) | ||
819 | 32 | self.assertFalse(res) | ||
820 | 33 | |||
821 | 34 | def test_against_that_works_with_no_additonal_deps(self): | ||
822 | 35 | res = self.cli.open(os.path.join(self.testdir, "gdebi-test3.deb")) | ||
823 | 36 | self.assertTrue(res) | ||
824 | 37 | self.assertEqual( | ||
825 | 38 | self.cli.get_dependencies_info(), "") | ||
826 | 39 | |||
827 | 40 | |||
828 | 41 | if __name__ == "__main__": | ||
829 | 42 | unittest.main() | ||
830 | 0 | 43 | ||
831 | === added file 'tests/test_gdebi_gtk.py' | |||
832 | --- tests/test_gdebi_gtk.py 1970-01-01 00:00:00 +0000 | |||
833 | +++ tests/test_gdebi_gtk.py 2012-10-12 16:06:23 +0000 | |||
834 | @@ -0,0 +1,34 @@ | |||
835 | 1 | #!/usr/bin/python | ||
836 | 2 | |||
837 | 3 | import os | ||
838 | 4 | import subprocess | ||
839 | 5 | import unittest | ||
840 | 6 | |||
841 | 7 | |||
842 | 8 | class GDebiGtkTestCase(unittest.TestCase): | ||
843 | 9 | |||
844 | 10 | @classmethod | ||
845 | 11 | def setUpClass(cls): | ||
846 | 12 | if not "DISPLAY" in os.environ: | ||
847 | 13 | DISPLAY = ":42" | ||
848 | 14 | cls.xvfb = subprocess.Popen(["Xvfb", DISPLAY]) | ||
849 | 15 | os.environ["DISPLAY"] = DISPLAY | ||
850 | 16 | else: | ||
851 | 17 | cls.xvfb = None | ||
852 | 18 | |||
853 | 19 | @classmethod | ||
854 | 20 | def tearDownClass(cls): | ||
855 | 21 | if cls.xvfb: | ||
856 | 22 | cls.xvfb.kill() | ||
857 | 23 | |||
858 | 24 | def setUp(self): | ||
859 | 25 | from GDebi.GDebiGtk import GDebiGtk | ||
860 | 26 | datadir = os.path.join(os.path.dirname(__file__), "..", "data") | ||
861 | 27 | self.app = GDebiGtk(datadir=datadir, options=None) | ||
862 | 28 | |||
863 | 29 | def test_simple(self): | ||
864 | 30 | self.assertNotEqual(self.app, None) | ||
865 | 31 | |||
866 | 32 | |||
867 | 33 | if __name__ == "__main__": | ||
868 | 34 | unittest.main() | ||
869 | 0 | 35 | ||
870 | === added file 'tests/test_pyflakes.py' | |||
871 | --- tests/test_pyflakes.py 1970-01-01 00:00:00 +0000 | |||
872 | +++ tests/test_pyflakes.py 2012-10-12 16:06:23 +0000 | |||
873 | @@ -0,0 +1,15 @@ | |||
874 | 1 | import os | ||
875 | 2 | import subprocess | ||
876 | 3 | import unittest | ||
877 | 4 | |||
878 | 5 | |||
879 | 6 | class TestPyflakesClean(unittest.TestCase): | ||
880 | 7 | """ ensure that the tree is pyflakes clean """ | ||
881 | 8 | |||
882 | 9 | def test_pyflakes_clean(self): | ||
883 | 10 | path = os.path.join(os.path.dirname(__file__), "..") | ||
884 | 11 | self.assertEqual(subprocess.call(["pyflakes", path]), 0) | ||
885 | 12 | |||
886 | 13 | |||
887 | 14 | if __name__ == "__main__": | ||
888 | 15 | unittest.main() |