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
=== modified file 'GDebi/DebPackage.py'
--- GDebi/DebPackage.py 2011-06-12 13:54:38 +0000
+++ GDebi/DebPackage.py 2012-10-12 16:06:23 +0000
@@ -24,7 +24,6 @@
24import apt.debfile24import apt.debfile
25from gettext import gettext as _25from gettext import gettext as _
2626
27from apt.debfile import DscSrcPackage
2827
29class DebPackage(apt.debfile.DebPackage):28class DebPackage(apt.debfile.DebPackage):
3029
@@ -33,8 +32,13 @@
33 self.downloaded = downloaded32 self.downloaded = downloaded
3433
35 def __getitem__(self,item):34 def __getitem__(self,item):
36 if not self._sections.has_key(item):35 if not item in self._sections:
37 # Translators: it's for missing entries in the deb package,36 # Translators: it's for missing entries in the deb package,
38 # e.g. a missing "Maintainer" field37 # e.g. a missing "Maintainer" field
39 return _("%s is not available") % item38 return _("%s is not available") % item
40 return self._sections[item]39 return self._sections[item]
40
41
42# just for compatibility
43class DscSrcPackage(apt.debfile.DscSrcPackage):
44 pass
4145
=== modified file 'GDebi/GDebiCli.py'
--- GDebi/GDebiCli.py 2012-10-11 20:09:58 +0000
+++ GDebi/GDebiCli.py 2012-10-12 16:06:23 +0000
@@ -23,20 +23,18 @@
2323
24import apt24import apt
25import apt_pkg25import apt_pkg
26import fcntl26import logging
27import os27import os
28import string
29import sys28import sys
30import time
31import thread
3229
33from gettext import gettext as _30from gettext import gettext as _
34from re import findall31from re import findall
32from subprocess import PIPE, Popen, call
3533
36from apt.cache import Cache34from apt.cache import Cache
37from DebPackage import DebPackage, DscSrcPackage35
3836from .DebPackage import DebPackage, DscSrcPackage
39from subprocess import PIPE, Popen, call37
4038
41class GDebiCli(object):39class GDebiCli(object):
4240
@@ -77,7 +75,8 @@
77 else:75 else:
78 sys.stderr.write(_("Unknown package type '%s', exiting\n") % file)76 sys.stderr.write(_("Unknown package type '%s', exiting\n") % file)
79 sys.exit(1)77 sys.exit(1)
80 except (IOError,SystemError,ValueError),e:78 except (IOError,SystemError,ValueError) as e:
79 logging.debug("error opening: %s" % e)
81 sys.stderr.write(_("Failed to open the software package\n"))80 sys.stderr.write(_("Failed to open the software package\n"))
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 "
83 "allowed to open the file. Check the permissions "82 "allowed to open the file. Check the permissions "
@@ -97,22 +96,27 @@
97 print _("No description is available")96 print _("No description is available")
9897
99 def show_dependencies(self):98 def show_dependencies(self):
99 print self.get_dependencies_info()
100
101 def get_dependencies_info(self):
102 s = ""
100 # show what changes103 # show what changes
101 (install, remove, unauthenticated) = self._deb.required_changes104 (install, remove, unauthenticated) = self._deb.required_changes
102 if len(unauthenticated) > 0:105 if len(unauthenticated) > 0:
103 print _("The following packages are UNAUTHENTICATED: ")106 s += _("The following packages are UNAUTHENTICATED: ")
104 for pkgname in unauthenticated:107 for pkgname in unauthenticated:
105 print pkgname + " ",108 s += pkgname + " "
106 if len(remove) > 0:109 if len(remove) > 0:
107 print _("Requires the REMOVAL of the following packages: ")110 s += _("Requires the REMOVAL of the following packages: ")
108 for pkgname in remove:111 for pkgname in remove:
109 print pkgname + " ",112 s += pkgname + " "
110 print113 s += "\n"
111 if len(install) > 0:114 if len(install) > 0:
112 print _("Requires the installation of the following packages: ") 115 s += _("Requires the installation of the following packages: ")
113 for pkgname in install:116 for pkgname in install:
114 print pkgname + " ",117 s += pkgname + " "
115 print118 s += "\n"
119 return s
116120
117 def install(self):121 def install(self):
118 # install the dependecnies122 # install the dependecnies
@@ -122,7 +126,8 @@
122 iprogress = apt.progress.base.InstallProgress()126 iprogress = apt.progress.base.InstallProgress()
123 try:127 try:
124 res = self._cache.commit(fprogress,iprogress)128 res = self._cache.commit(fprogress,iprogress)
125 except(apt.cache.FetchFailedException, SystemError) e:129 logging.debug("commit() returned %s" % res)
130 except(apt.cache.FetchFailedException, SystemError) as e:
126 sys.stderr.write(_("Error during install: '%s'") % e)131 sys.stderr.write(_("Error during install: '%s'") % e)
127 return 1132 return 1
128133
129134
=== modified file 'GDebi/GDebiCommon.py'
--- GDebi/GDebiCommon.py 2012-09-12 21:28:17 +0000
+++ GDebi/GDebiCommon.py 2012-10-12 16:06:23 +0000
@@ -21,24 +21,21 @@
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22#22#
2323
2424import gettext
25import sys25import logging
26import os26import os
27import string
28import warnings
29warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
30from mimetypes import guess_type27from mimetypes import guess_type
3128
32import apt
33import apt_pkg29import apt_pkg
34
35from apt.cache import Cache30from apt.cache import Cache
36from DebPackage import DebPackage31
37import gettext32from .DebPackage import DebPackage
33
3834
39def _(str):35def _(str):
40 return utf8(gettext.gettext(str))36 return utf8(gettext.gettext(str))
4137
38
42def utf8(str):39def utf8(str):
43 if isinstance(str, unicode):40 if isinstance(str, unicode):
44 return str41 return str
@@ -47,6 +44,7 @@
47 except:44 except:
48 # assume latin1 as fallback45 # assume latin1 as fallback
49 return unicode(str, 'latin1')46 return unicode(str, 'latin1')
47
50 48
51class GDebiCommon(object):49class GDebiCommon(object):
52 # cprogress may be different in child classes50 # cprogress may be different in child classes
@@ -56,7 +54,7 @@
56 self.version_info_title = ""54 self.version_info_title = ""
57 self.version_info_msg = ""55 self.version_info_msg = ""
58 self._deb = None56 self._deb = None
59 self._options = options57 self._options = options
60 self.install = []58 self.install = []
61 self.remove = []59 self.remove = []
62 self.unauthenticated = 060 self.unauthenticated = 0
@@ -71,14 +69,15 @@
71 "To fix it run 'gksudo synaptic' or "69 "To fix it run 'gksudo synaptic' or "
72 "'sudo apt-get install -f' "70 "'sudo apt-get install -f' "
73 "in a terminal window.")71 "in a terminal window.")
74 return False72 return False
75 return True73 return True
7674
77 def open(self, file, downloaded=False):75 def open(self, file, downloaded=False):
78 file = os.path.abspath(file)76 file = os.path.abspath(file)
79 try:77 try:
80 self._deb = DebPackage(file, self._cache, downloaded)78 self._deb = DebPackage(file, self._cache, downloaded)
81 except (IOError,SystemError,ValueError),e:79 except (IOError, SystemError, ValueError) as e:
80 logging.debug("open failed with %s" % e)
82 mimetype=guess_type(file)81 mimetype=guess_type(file)
83 if (mimetype[0] != None and 82 if (mimetype[0] != None and
84 mimetype[0] != "application/x-debian-package"):83 mimetype[0] != "application/x-debian-package"):
8584
=== renamed file 'GDebi/GDebi.py' => 'GDebi/GDebiGtk.py'
--- GDebi/GDebi.py 2012-10-11 20:09:07 +0000
+++ GDebi/GDebiGtk.py 2012-10-12 16:06:23 +0000
@@ -31,7 +31,7 @@
31import sys31import sys
32import time32import time
33import tempfile33import tempfile
34import thread34import threading
35import urllib35import urllib
3636
37import gi37import gi
@@ -45,12 +45,13 @@
45from gi.repository import Vte45from gi.repository import Vte
46from gi.repository import Gio46from gi.repository import Gio
4747
48from DebPackage import DebPackage
49from SimpleGtkbuilderApp import SimpleGtkbuilderApp
50from apt.progress.base import InstallProgress48from apt.progress.base import InstallProgress
51from GDebiCommon import GDebiCommon, utf8
52from gettext import gettext as _49from gettext import gettext as _
5350
51from .DebPackage import DebPackage
52from .SimpleGtkbuilderApp import SimpleGtkbuilderApp
53from .GDebiCommon import GDebiCommon, utf8
54
54# the timeout when the termial is expanded if no activity from dpkg55# the timeout when the termial is expanded if no activity from dpkg
55# is happening 56# is happening
56GDEBI_TERMINAL_TIMEOUT=4*60.057GDEBI_TERMINAL_TIMEOUT=4*60.0
@@ -61,27 +62,24 @@
61try:62try:
62 import lsb_release63 import lsb_release
63 UBUNTU = lsb_release.get_distro_information()['ID'] == 'Ubuntu'64 UBUNTU = lsb_release.get_distro_information()['ID'] == 'Ubuntu'
64except Exception, e:65except Exception as e:
65 pass66 pass
6667
67class GDebi(SimpleGtkbuilderApp, GDebiCommon):68class GDebiGtk(SimpleGtkbuilderApp, GDebiCommon):
6869
69 def __init__(self, datadir, options, file=""):70 def __init__(self, datadir, options, file=""):
70 GDebiCommon.__init__(self,datadir,options,file)71 GDebiCommon.__init__(self,datadir,options,file)
71 localesApp="gdebi"
72 localesDir="/usr/share/locale"
73
74 SimpleGtkbuilderApp.__init__(72 SimpleGtkbuilderApp.__init__(
75 self, path=datadir+"/gdebi.ui", domain="gdebi")73 self, path=os.path.join(datadir, "gdebi.ui"), domain="gdebi")
74
76 # use a nicer default icon75 # use a nicer default icon
77 icons = Gtk.IconTheme.get_default()76 icons = Gtk.IconTheme.get_default()
78 try:77 try:
79 logo=icons.load_icon("gnome-mime-application-x-deb", 48, 0)78 logo=icons.load_icon("gnome-mime-application-x-deb", 48, 0)
80 if logo != "":79 if logo != "":
81 Gtk.Window.set_default_icon_list([logo])80 Gtk.Window.set_default_icon_list([logo])
82 except Exception, e:81 except Exception as e:
83 print "Error loading logo"82 logging.warn("Error loading logo %s" % e)
84 pass
8583
86 # create terminal84 # create terminal
87 self.vte_terminal = Vte.Terminal()85 self.vte_terminal = Vte.Terminal()
@@ -193,7 +191,7 @@
193 self.gio_progress_callback, 0):191 self.gio_progress_callback, 0):
194 file = gio_dest.get_path()192 file = gio_dest.get_path()
195 self.dialog_gio_download.hide()193 self.dialog_gio_download.hide()
196 except Exception, e:194 except Exception as e:
197 self.show_alert(Gtk.MessageType.ERROR, 195 self.show_alert(Gtk.MessageType.ERROR,
198 _("Download failed"),196 _("Download failed"),
199 _("Downloading the package failed: "197 _("Downloading the package failed: "
@@ -255,7 +253,7 @@
255 buf = self.textview_description.get_buffer()253 buf = self.textview_description.get_buffer()
256 try:254 try:
257 long_desc = ""255 long_desc = ""
258 raw_desc = string.split(utf8(self._deb["Description"]), "\n")256 raw_desc = utf8(self._deb["Description"]).split("\n")
259 # append a newline to the summary in the first line257 # append a newline to the summary in the first line
260 summary = raw_desc[0]258 summary = raw_desc[0]
261 raw_desc[0] = ""259 raw_desc[0] = ""
@@ -306,8 +304,8 @@
306 header = store.append(None, [_("Upstream data")])304 header = store.append(None, [_("Upstream data")])
307 for name in self._deb.filelist:305 for name in self._deb.filelist:
308 store.append(header, [name])306 store.append(header, [name])
309 except Exception, e:307 except Exception as e:
310 print "Exception while reading the filelist: '%s'" % e308 logging.exception("Exception while reading the filelist: '%s'" % e)
311 store.clear()309 store.clear()
312 store.append(None, [_("Error reading filelist")])310 store.append(None, [_("Error reading filelist")])
313 self.treeview_files.set_model(store)311 self.treeview_files.set_model(store)
@@ -324,7 +322,7 @@
324 #glib.markup_escape_text(self._deb._failure_string) +322 #glib.markup_escape_text(self._deb._failure_string) +
325 self._deb._failure_string + 323 self._deb._failure_string +
326 "</span>")324 "</span>")
327 self.button_install.set_label(_("_Install Package"))325 self.button_install.set_label(_("_Install Package"))
328326
329 self.button_install.set_sensitive(False)327 self.button_install.set_sensitive(False)
330 self.button_details.hide()328 self.button_details.hide()
@@ -404,12 +402,12 @@
404 elif parent_path == 0:402 elif parent_path == 0:
405 try:403 try:
406 data = self._deb.control_content(name)404 data = self._deb.control_content(name)
407 except Exception, e:405 except Exception as e:
408 data = _("Error reading file content '%s'") % e406 data = _("Error reading file content '%s'") % e
409 elif parent_path == 1:407 elif parent_path == 1:
410 try:408 try:
411 data = self._deb.data_content(name)409 data = self._deb.data_content(name)
412 except Exception, e:410 except Exception as e:
413 data = _("Error reading file content '%s'") % e411 data = _("Error reading file content '%s'") % e
414 else:412 else:
415 assert False, "NOT REACHED"413 assert False, "NOT REACHED"
@@ -477,7 +475,7 @@
477475
478 def on_about_activate(self, widget):476 def on_about_activate(self, widget):
479 #print "about"477 #print "about"
480 from Version import VERSION478 from .Version import VERSION
481 self.dialog_about.set_version(VERSION)479 self.dialog_about.set_version(VERSION)
482 self.dialog_about.run()480 self.dialog_about.run()
483 self.dialog_about.hide()481 self.dialog_about.hide()
@@ -620,16 +618,16 @@
620 self.vte_terminal,618 self.vte_terminal,
621 self.label_action,619 self.label_action,
622 self.expander_install)620 self.expander_install)
623 errMsg = None621 #errMsg = None
624 try:622 try:
625 res = self._cache.commit(fprogress,iprogress)623 res = self._cache.commit(fprogress,iprogress)
626 except IOError, msg:624 except IOError as msg:
627 res = False625 res = False
628 errMsg = "%s" % msg626 #errMsg = "%s" % msg
629 header = _("Could not download all required files")627 header = _("Could not download all required files")
630 body = _("Please check your internet connection or "628 body = _("Please check your internet connection or "
631 "installation medium.")629 "installation medium.")
632 except SystemError, msg:630 except SystemError as msg:
633 res = False631 res = False
634 header = _("Could not install all dependencies"),632 header = _("Could not install all dependencies"),
635 body = _("Usually this is related to an error of the "633 body = _("Usually this is related to an error of the "
@@ -817,7 +815,7 @@
817 logging.exception("lock.release failed")815 logging.exception("lock.release failed")
818816
819 # get a lock817 # get a lock
820 lock = thread.allocate_lock()818 lock = threading.Lock()
821 lock.acquire()819 lock.acquire()
822820
823 # ui821 # ui
@@ -872,17 +870,17 @@
872 while True:870 while True:
873 try:871 try:
874 read += os.read(readfd,1)872 read += os.read(readfd,1)
875 except OSError, (errno,errstr):873 except OSError as e:
876 # resource temporarly unavailable is ignored874 # resource temporarly unavailable is ignored
877 from errno import EAGAIN875 from errno import EAGAIN
878 if errno != EAGAIN:876 if e.errno != EAGAIN:
879 print errstr877 logging.warn(e.errstr)
880 break878 break
881 self.time_last_update = time.time()879 self.time_last_update = time.time()
882 if read.endswith("\n"):880 if read.endswith("\n"):
883 statusl = string.split(read, ":")881 statusl = read.split(":")
884 if len(statusl) < 3:882 if len(statusl) < 3:
885 print "got garbage from dpkg: '%s'" % read883 logging.warn("got garbage from dpkg: '%s'" % read)
886 read = ""884 read = ""
887 break885 break
888 status = statusl[2].strip()886 status = statusl[2].strip()
@@ -968,19 +966,19 @@
968 966
969 class FetchProgressAdapter(apt.progress.base.AcquireProgress):967 class FetchProgressAdapter(apt.progress.base.AcquireProgress):
970 def __init__(self,progress,action,main):968 def __init__(self,progress,action,main):
971 super(GDebi.FetchProgressAdapter, self).__init__()969 super(GDebiGtk.FetchProgressAdapter, self).__init__()
972 self.progress = progress970 self.progress = progress
973 self.action = action971 self.action = action
974 self.main = main972 self.main = main
975 def start(self):973 def start(self):
976 super(GDebi.FetchProgressAdapter, self).start()974 super(GDebiGtk.FetchProgressAdapter, self).start()
977 self.action.set_markup("<i>"+_("Downloading additional package files...")+"</i>")975 self.action.set_markup("<i>"+_("Downloading additional package files...")+"</i>")
978 self.progress.set_fraction(0)976 self.progress.set_fraction(0)
979 def stop(self):977 def stop(self):
980 #print "stop()"978 #print "stop()"
981 pass979 pass
982 def pulse(self, owner):980 def pulse(self, owner):
983 super(GDebi.FetchProgressAdapter, self).pulse(owner)981 super(GDebiGtk.FetchProgressAdapter, self).pulse(owner)
984 at_item = min(self.current_items + 1, self.total_items)982 at_item = min(self.current_items + 1, self.total_items)
985 if self.current_cps > 0:983 if self.current_cps > 0:
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)))
@@ -1017,18 +1015,19 @@
1017 Gtk.main_iteration()1015 Gtk.main_iteration()
1018 def done(self):1016 def done(self):
1019 self.progressbar.hide()1017 self.progressbar.hide()
1020 1018
1019
1021if __name__ == "__main__":1020if __name__ == "__main__":
1022 app = GDebi("data/",None)1021 app = GDebiGtk("data/",None)
10231022
1024 pkgs = ["cw"]1023 pkgs = ["cw"]
1025 for pkg in pkgs:1024 for pkg in pkgs:
1026 print "installing %s" % pkg1025 print("installing %s" % pkg)
1027 app._cache[pkg].mark_install()1026 app._cache[pkg].mark_install()
10281027
1029 for pkg in app._cache:1028 for pkg in app._cache:
1030 if pkg.marked_install or pkg.marked_upgrade:1029 if pkg.marked_install or pkg.marked_upgrade:
1031 print pkg.name1030 print(pkg.name)
10321031
1033 apt_pkg.pkgsystem_lock()1032 apt_pkg.pkgsystem_lock()
1034 app.dialog_deb_install.set_transient_for(app.window_main)1033 app.dialog_deb_install.set_transient_for(app.window_main)
@@ -1043,6 +1042,6 @@
1043 app.label_action,1042 app.label_action,
1044 app.expander_install)1043 app.expander_install)
1045 res = app._cache.commit(fprogress,iprogress)1044 res = app._cache.commit(fprogress,iprogress)
1046 print "commit retured: %s" % res1045 print("commit retured: %s" % res)
1047 1046
1048 Gtk.main()1047 Gtk.main()
10491048
=== modified file 'GDebi/GDebiKDE.py'
--- GDebi/GDebiKDE.py 2012-09-13 20:50:23 +0000
+++ GDebi/GDebiKDE.py 2012-10-12 16:06:23 +0000
@@ -22,27 +22,47 @@
22# You should have received a copy of the GNU General Public License22# You should have received a copy of the GNU General Public License
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/>.
2424
25import logging
25import os26import os
26import subprocess27import re
27import string28import string
28import re29import sys
29import pty30
30import warnings31
31warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)32from PyKDE4.kdeui import (
32import apt_pkg33 KApplication,
3334 KIcon,
34from PyKDE4.kdecore import *35 KMessageBox,
35from PyKDE4.kdeui import *36 DesktopIcon,
36from PyQt4.QtCore import *37 )
37from PyQt4.QtGui import *38from PyQt4.QtCore import (
39 Qt,
40 SIGNAL,
41 QStringList,
42 QTimer,
43 )
44from PyQt4.QtGui import (
45 QDialog,
46 QHBoxLayout,
47 QTextCursor,
48 QTextEdit,
49 QTextOption,
50 )
38from PyQt4 import uic51from PyQt4 import uic
3952
40from apt.cache import Cache53from apt.cache import Cache
41from DebPackage import DebPackage
4254
43import gettext55import gettext
44from GDebiCommon import GDebiCommon, utf8, _56
45from KDEAptDialogs import *57from .DebPackage import DebPackage
58from .GDebiCommon import GDebiCommon, utf8, _
59from .KDEAptDialogs import (
60 CacheProgressAdapter,
61 KDEDpkgInstallProgress,
62 KDEFetchProgressAdapter,
63 KDEInstallProgressAdapter,
64 )
65
4666
47def __(catalog,str):67def __(catalog,str):
48 return unicode(gettext.dgettext(catalog, str), 'UTF-8')68 return unicode(gettext.dgettext(catalog, str), 'UTF-8')
@@ -109,19 +129,23 @@
109 return129 return
110 # block signals so that we do not run into a recursion130 # block signals so that we do not run into a recursion
111 self._block = True131 self._block = True
112 para = self.paragraphs() - 1132 #para = self.paragraphs() - 1
113 pos = self.paragraphLength(para)133 #pos = self.paragraphLength(para)
114 self.moveCursor(QTextCursor.End)134 self.moveCursor(QTextCursor.End)
115 self._block = False135 self._block = False
116136
137
117class GDebiKDEDialog(QDialog):138class GDebiKDEDialog(QDialog):
118 """Our main user interface, load from UI file"""139 """Our main user interface, load from UI file"""
119 def __init__(self, parent):140 def __init__(self, parent):
120 QDialog.__init__(self, parent)141 QDialog.__init__(self, parent)
121 loadUi("GDebiKDEDialog.ui", self)142 loadUi("GDebiKDEDialog.ui", self)
122143
144
123class GDebiKDE(GDebiCommon, GDebiKDEDialog):145class GDebiKDE(GDebiCommon, GDebiKDEDialog):
124 def __init__(self,datadir,options,file="",parent = None,name = None,modal = 0,fl = 0):146
147 def __init__(self, datadir, options, file="", parent=None, name=None,
148 modal=0, fl=0):
125 GDebiKDEDialog.__init__(self,parent)149 GDebiKDEDialog.__init__(self,parent)
126 GDebiCommon.__init__(self,datadir,options,file)150 GDebiCommon.__init__(self,datadir,options,file)
127 # load the icon151 # load the icon
@@ -291,9 +315,10 @@
291 for r in remove:315 for r in remove:
292 changedList.append(_("To be removed: %s") % r)316 changedList.append(_("To be removed: %s") % r)
293317
294 infoReport = KMessageBox.informationList(self,318 KMessageBox.informationList(
295 _("<b>To install the following changes are required:</b>"),319 self,
296 changedList, _("Details"))320 _("<b>To install the following changes are required:</b>"),
321 changedList, _("Details"))
297322
298 def installButtonClicked(self):323 def installButtonClicked(self):
299 # if not root, start a new instance324 # if not root, start a new instance
@@ -336,16 +361,17 @@
336 self.installDialog.installingLabel,361 self.installDialog.installingLabel,
337 self.installDialog)362 self.installDialog)
338 self.installDialog.konsole.setInstallProgress(iprogress)363 self.installDialog.konsole.setInstallProgress(iprogress)
339 errMsg = None364 #errMsg = None
340 try:365 try:
341 res = self._cache.commit(fprogress,iprogress)366 res = self._cache.commit(fprogress,iprogress)
342 except IOError, msg:367 except IOError as msg:
343 res = False368 res = False
344 errMsg = "%s" % msg369 #errMsg = "%s" % msg
345 header = _("Could not download all required files")370 header = _("Could not download all required files")
346 body = _("Please check your internet connection or "371 body = _("Please check your internet connection or "
347 "installation medium.")372 "installation medium.")
348 except SystemError, msg:373 except SystemError as msg:
374 logging.warn("error: %s" % msg)
349 res = False375 res = False
350 header = _("Could not install all dependencies")376 header = _("Could not install all dependencies")
351 body = _("Usually this is related to an error of the "377 body = _("Usually this is related to an error of the "
352378
=== modified file 'GDebi/KDEAptDialogs.py'
--- GDebi/KDEAptDialogs.py 2011-08-16 08:05:17 +0000
+++ GDebi/KDEAptDialogs.py 2012-10-12 16:06:23 +0000
@@ -22,31 +22,28 @@
22# You should have received a copy of the GNU General Public License22# You should have received a copy of the GNU General Public License
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/>.
2424
25import sys25import logging
26import os26import os
27import subprocess27import subprocess
28import string28
29import apt29import apt
30import apt_pkg30import apt_pkg
31from PyKDE4.kdecore import *31
32from PyKDE4.kdeui import *32from PyKDE4.kdeui import (
33from PyQt4.QtCore import *33 KApplication,
34from PyQt4.QtGui import *34 KMessageBox,
3535 KStandardGuiItem,
36import urllib36 )
37import fcntl37from PyQt4.QtCore import (
38import posix38 QTimer,
39import time39 )
40import thread40
41import re
42import pty41import pty
43import select42import select
4443
45from apt.cache import Cache
46from apt.debfile import DebPackage
47from apt.progress.base import InstallProgress44from apt.progress.base import InstallProgress
48from gettext import gettext as gett45
49from GDebiCommon import utf8, _46from .GDebiCommon import utf8, _
5047
5148
52class KDEDpkgInstallProgress(object):49class KDEDpkgInstallProgress(object):
@@ -66,7 +63,7 @@
66 self.progress.setValue(0)63 self.progress.setValue(0)
6764
68 def timeoutHandler(self,signum, frame):65 def timeoutHandler(self,signum, frame):
69 raise IOError, "Stopped waiting for I/O."66 raise IOError("Stopped waiting for I/O.")
7067
71 def commit(self):68 def commit(self):
72 # ui69 # ui
@@ -78,7 +75,7 @@
7875
79 if self.child_pid == 0:76 if self.child_pid == 0:
80 os.environ["TERM"] = "dumb"77 os.environ["TERM"] = "dumb"
81 if not os.environ.has_key("DEBIAN_FRONTEND"):78 if not "DEBIAN_FRONTEND" in os.environ:
82 os.environ["DEBIAN_FRONTEND"] = "noninteractive"79 os.environ["DEBIAN_FRONTEND"] = "noninteractive"
83 os.environ["APT_LISTCHANGES_FRONTEND"] = "none"80 os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
84 exitstatus = subprocess.call(argv)81 exitstatus = subprocess.call(argv)
@@ -91,7 +88,7 @@
91 if len(rlist) > 0:88 if len(rlist) > 0:
92 line = os.read(self.master_fd, 255)89 line = os.read(self.master_fd, 255)
93 self.parent.konsole.insertWithTermCodes(utf8(line))90 self.parent.konsole.insertWithTermCodes(utf8(line))
94 except Exception, e:91 except Exception as e:
95 #print e92 #print e
96 from errno import EAGAIN93 from errno import EAGAIN
97 if hasattr(e, "errno") and e.errno == EAGAIN:94 if hasattr(e, "errno") and e.errno == EAGAIN:
@@ -150,7 +147,7 @@
150 # run the base class147 # run the base class
151 try:148 try:
152 InstallProgress.updateInterface(self)149 InstallProgress.updateInterface(self)
153 except ValueError,e:150 except ValueError as e:
154 pass151 pass
155 # log the output of dpkg (on the master_fd) to the DumbTerminal152 # log the output of dpkg (on the master_fd) to the DumbTerminal
156 while True:153 while True:
@@ -163,8 +160,8 @@
163 else:160 else:
164 # nothing happend within the timeout, break161 # nothing happend within the timeout, break
165 break162 break
166 except Exception, e:163 except Exception as e:
167 #print "updateInterface: ", e164 logging.debug("updateInterface: " % e)
168 break165 break
169 KApplication.kApplication().processEvents()166 KApplication.kApplication().processEvents()
170167
@@ -173,7 +170,7 @@
173 (self.child_pid, self.master_fd) = pty.fork()170 (self.child_pid, self.master_fd) = pty.fork()
174 if self.child_pid == 0:171 if self.child_pid == 0:
175 os.environ["TERM"] = "dumb"172 os.environ["TERM"] = "dumb"
176 if not os.environ.has_key("DEBIAN_FRONTEND"):173 if not "DEBIAN_FRONTEND" in os.environ:
177 os.environ["DEBIAN_FRONTEND"] = "noninteractive"174 os.environ["DEBIAN_FRONTEND"] = "noninteractive"
178 os.environ["APT_LISTCHANGES_FRONTEND"] = "none"175 os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
179 return self.child_pid176 return self.child_pid
@@ -182,8 +179,8 @@
182 while True:179 while True:
183 try:180 try:
184 select.select([self.statusfd],[],[], self.select_timeout)181 select.select([self.statusfd],[],[], self.select_timeout)
185 except Exception, e:182 except Exception as e:
186 #print "waitChild: ", e183 logging.debug("waitChild: " % e)
187 pass184 pass
188 self.updateInterface()185 self.updateInterface()
189 (pid, res) = os.waitpid(self.child_pid,os.WNOHANG)186 (pid, res) = os.waitpid(self.child_pid,os.WNOHANG)
190187
=== modified file 'GDebi/SimpleGtkbuilderApp.py'
--- GDebi/SimpleGtkbuilderApp.py 2011-05-25 16:22:00 +0000
+++ GDebi/SimpleGtkbuilderApp.py 2012-10-12 16:06:23 +0000
@@ -20,9 +20,6 @@
20# USA20# USA
2121
22import logging22import logging
23import os
24import sys
25import re
2623
27from gi.repository import Gtk24from gi.repository import Gtk
2825
2926
=== modified file 'debian/control'
--- debian/control 2012-09-12 21:17:04 +0000
+++ debian/control 2012-10-12 16:06:23 +0000
@@ -6,6 +6,7 @@
6 Michael Vogt <mvo@debian.org>6 Michael Vogt <mvo@debian.org>
7Build-Depends: debhelper (>= 8),7Build-Depends: debhelper (>= 8),
8 python (>= 2.6.6-3~),8 python (>= 2.6.6-3~),
9 python-setuptools,
9 intltool10 intltool
10X-Python-Version: >= 2.611X-Python-Version: >= 2.6
11Standards-Version: 3.9.312Standards-Version: 3.9.3
1213
=== modified file 'gdebi'
--- gdebi 2012-09-13 09:44:20 +0000
+++ gdebi 2012-10-12 16:06:23 +0000
@@ -78,7 +78,7 @@
7878
79 try:79 try:
80 debi = GDebiCli(options)80 debi = GDebiCli(options)
81 except SystemError, e:81 except SystemError as e:
82 print "Error opening the cache:\n%s" % e82 print "Error opening the cache:\n%s" % e
83 sys.exit(1)83 sys.exit(1)
84 if not debi.open(args[0]):84 if not debi.open(args[0]):
8585
=== modified file 'gdebi-gtk'
--- gdebi-gtk 2012-09-12 22:03:35 +0000
+++ gdebi-gtk 2012-10-12 16:06:23 +0000
@@ -28,7 +28,7 @@
2828
2929
30from optparse import OptionParser30from optparse import OptionParser
31from GDebi.GDebi import GDebi31from GDebi.GDebiGtk import GDebiGtk
3232
33from gettext import gettext as _33from gettext import gettext as _
34import gettext34import gettext
@@ -64,7 +64,7 @@
6464
65 try:65 try:
66 Gtk.init_check(sys.argv)66 Gtk.init_check(sys.argv)
67 except RuntimeError, e:67 except RuntimeError as e:
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))
69 sys.exit(1)69 sys.exit(1)
7070
@@ -73,8 +73,8 @@
73 afile = args[0]73 afile = args[0]
74 74
75 try:75 try:
76 app = GDebi(datadir=data,options=options,file=afile)76 app = GDebiGtk(datadir=data,options=options,file=afile)
77 except SystemError, e:77 except SystemError as e:
78 err_header = _("Software index is broken")78 err_header = _("Software index is broken")
79 err_body = _("This is a major failure of your software " 79 err_body = _("This is a major failure of your software "
80 "management system. Please check for broken packages "80 "management system. Please check for broken packages "
8181
=== modified file 'gdebi-kde'
--- gdebi-kde 2012-09-12 22:03:35 +0000
+++ gdebi-kde 2012-10-12 16:06:23 +0000
@@ -103,7 +103,7 @@
103 if options.non_interactive == True:103 if options.non_interactive == True:
104 gdebi.installButtonClicked()104 gdebi.installButtonClicked()
105 app.exec_()105 app.exec_()
106 except SystemError, e:106 except SystemError as e:
107 err_header = _("Software index is broken")107 err_header = _("Software index is broken")
108 err_body = _("This is a major failure of your software " 108 err_body = _("This is a major failure of your software "
109 "management system. Please check for broken packages "109 "management system. Please check for broken packages "
110110
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2010-07-02 14:52:39 +0000
+++ po/POTFILES.in 2012-10-12 16:06:23 +0000
@@ -6,7 +6,7 @@
6data/gdebi.desktop.in6data/gdebi.desktop.in
7gdebi-gtk7gdebi-gtk
8GDebi/DebPackage.py8GDebi/DebPackage.py
9GDebi/GDebi.py9GDebi/GDebiGtk.py
10GDebi/GDebiCli.py10GDebi/GDebiCli.py
11GDebi/GDebiKDE.py11GDebi/GDebiKDE.py
12GDebi/GDebiCommon.py12GDebi/GDebiCommon.py
1313
=== modified file 'setup.py'
--- setup.py 2011-08-28 14:22:30 +0000
+++ setup.py 2012-10-12 16:06:23 +0000
@@ -1,7 +1,7 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3import os3import os
4from distutils.core import setup4from setuptools import setup
5from glob import glob5from glob import glob
6from re import compile6from re import compile
77
@@ -26,6 +26,7 @@
2626
27s = setup(name='gdebi',27s = setup(name='gdebi',
28 version=version,28 version=version,
29 test_suite="tests",
29 packages=['GDebi'],30 packages=['GDebi'],
30 scripts=['gdebi', 'gdebi-gtk', 'gdebi-kde'],31 scripts=['gdebi', 'gdebi-gtk', 'gdebi-kde'],
31 data_files=[('share/gdebi/',32 data_files=[('share/gdebi/',
3233
=== added file 'tests/__init__.py'
=== added file 'tests/test_gdebi_cli.py'
--- tests/test_gdebi_cli.py 1970-01-01 00:00:00 +0000
+++ tests/test_gdebi_cli.py 2012-10-12 16:06:23 +0000
@@ -0,0 +1,42 @@
1#!/usr/bin/python
2
3import os
4import unittest
5
6from mock import Mock
7
8from GDebi.GDebiCli import GDebiCli
9
10
11class GDebiCliTestCase(unittest.TestCase):
12
13 @classmethod
14 def setUpClass(cls):
15 # use classmethod to speed up the tests as the cache is only
16 # read once
17 cls.testdir = os.path.join(os.path.dirname(__file__))
18 mock_options = Mock()
19 mock_options.rootdir = None
20 mock_options.apt_opts = []
21 cls.cli = GDebiCli(options=mock_options)
22
23 def test_against_deb_with_conflict_against_apt(self):
24 res = self.cli.open(os.path.join(self.testdir, "gdebi-test1.deb"))
25 self.assertFalse(res)
26 self.assertEqual(
27 self.cli._deb._failure_string,
28 "Conflicts with the installed package 'apt'")
29
30 def test_against_impossible_dep(self):
31 res = self.cli.open(os.path.join(self.testdir, "gdebi-test2.deb"))
32 self.assertFalse(res)
33
34 def test_against_that_works_with_no_additonal_deps(self):
35 res = self.cli.open(os.path.join(self.testdir, "gdebi-test3.deb"))
36 self.assertTrue(res)
37 self.assertEqual(
38 self.cli.get_dependencies_info(), "")
39
40
41if __name__ == "__main__":
42 unittest.main()
043
=== added file 'tests/test_gdebi_gtk.py'
--- tests/test_gdebi_gtk.py 1970-01-01 00:00:00 +0000
+++ tests/test_gdebi_gtk.py 2012-10-12 16:06:23 +0000
@@ -0,0 +1,34 @@
1#!/usr/bin/python
2
3import os
4import subprocess
5import unittest
6
7
8class GDebiGtkTestCase(unittest.TestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 if not "DISPLAY" in os.environ:
13 DISPLAY = ":42"
14 cls.xvfb = subprocess.Popen(["Xvfb", DISPLAY])
15 os.environ["DISPLAY"] = DISPLAY
16 else:
17 cls.xvfb = None
18
19 @classmethod
20 def tearDownClass(cls):
21 if cls.xvfb:
22 cls.xvfb.kill()
23
24 def setUp(self):
25 from GDebi.GDebiGtk import GDebiGtk
26 datadir = os.path.join(os.path.dirname(__file__), "..", "data")
27 self.app = GDebiGtk(datadir=datadir, options=None)
28
29 def test_simple(self):
30 self.assertNotEqual(self.app, None)
31
32
33if __name__ == "__main__":
34 unittest.main()
035
=== added file 'tests/test_pyflakes.py'
--- tests/test_pyflakes.py 1970-01-01 00:00:00 +0000
+++ tests/test_pyflakes.py 2012-10-12 16:06:23 +0000
@@ -0,0 +1,15 @@
1import os
2import subprocess
3import unittest
4
5
6class TestPyflakesClean(unittest.TestCase):
7 """ ensure that the tree is pyflakes clean """
8
9 def test_pyflakes_clean(self):
10 path = os.path.join(os.path.dirname(__file__), "..")
11 self.assertEqual(subprocess.call(["pyflakes", path]), 0)
12
13
14if __name__ == "__main__":
15 unittest.main()

Subscribers

People subscribed via source and target branches

to status/vote changes: