Merge lp:~mvo/gdebi/py3compat into lp:gdebi

Proposed by Michael Vogt
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
Reviewer Review Type Date Requested Status
gdebi-developers Pending
Review via email: mp+129383@code.launchpad.net

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

Subscribers

People subscribed via source and target branches

to status/vote changes: