Merge lp:~brian-murray/update-notifier/python3 into lp:update-notifier/ubuntu

Proposed by Brian Murray
Status: Merged
Merged at revision: 716
Proposed branch: lp:~brian-murray/update-notifier/python3
Merge into: lp:update-notifier/ubuntu
Diff against target: 552 lines (+106/-74)
8 files modified
data/apt_check.py (+35/-25)
data/backend_helper.py (+17/-14)
data/hooks.py (+25/-19)
data/package-data-downloader (+9/-7)
debian/changelog (+9/-0)
debian/control (+9/-7)
debian/rules (+1/-1)
tests/test_package-data-downloader.py (+1/-1)
To merge this branch: bzr merge lp:~brian-murray/update-notifier/python3
Reviewer Review Type Date Requested Status
Adam Conrad Pending
Steve Langasek Pending
Review via email: mp+110429@code.launchpad.net

This proposal supersedes a proposal from 2012-06-13.

Description of the change

Porting of update-notifier to python3.

This is also dependent on python3-debian being available.

To post a comment you must log in.
Revision history for this message
Adam Conrad (adconrad) wrote : Posted in a previous version of this proposal

Looks good to me, with the latest revision.

review: Approve
Revision history for this message
Steve Langasek (vorlon) wrote : Posted in a previous version of this proposal

+ outstream.write("\n".join(map([p.name for p in pkgs])))

isn't the map() redundant here?

-SYNPATIC_DESKTOP = ["--desktop",
- "/usr/share/applications/synaptic.desktop",
+SYNPATIC_DESKTOP = ["--desktop",
+ "/usr/share/applications/synaptic.desktop",

Unrelated, but I guess the variable name could be spell-checked :)

There's one point in the data/package-data-downloader massive PEP8 fix-up (sorry about that) where I notice the indent level has changed (a couple of lines that were outside of 'with' blocks have been moved into them). That one's an ok no-op, but it makes me wonder if there are any others hiding in the large diff. Was the PEP8 reformatting of the file done automatically, or by hand? I don't think an eyeball review of the diff is useful to catch any bugs here, so we should probably rely on a sane automatic transformation.

review: Approve
Revision history for this message
Steve Langasek (vorlon) wrote : Posted in a previous version of this proposal

Merge conflict from landing the PEP8 whitespace changes separately on each branch; should be resolved so we can review.

review: Needs Fixing
Revision history for this message
Brian Murray (brian-murray) wrote : Posted in a previous version of this proposal

My local diff of package-data-downloader is only showing the following:

--- ../main/data/package-data-downloader 2012-06-13 15:54:04.000000000 -0700
+++ data/package-data-downloader 2012-06-13 15:51:18.000000000 -0700
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 """Process new requests to download per-package data"""
 # Copyright (C) 2012 Canonical Ltd
@@ -16,13 +16,15 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

+from __future__ import print_function
+
 import glob
 import os
 import sys
 import subprocess
 import re
 import traceback
-import urllib
+import urllib.request
 import debian.deb822
 import string
 import apt
@@ -184,7 +186,7 @@ def process_download_requests():
                 pass

         if proxies:
- urllib._urlopener = urllib.FancyURLopener(proxies)
+ urllib.request._urlopener = urllib.request.FancyURLopener(proxies)
     except Exception:
         pass

@@ -209,13 +211,13 @@ def process_download_requests():
         files = []
         sums = []
         for para in hook.iter_paragraphs(open(file)):
- if para.has_key('script'):
+ if 'script' in para:
                 if not files:
                     record_failure(relfile)
                     break
                 command = [para['script']]

- if para.has_key('should-download'):
+ if 'should-download' in para:
                     db = debconf.DebconfCommunicator('update-notifier')
                     try:
                         should = db.get(para['should-download'])
@@ -230,8 +232,8 @@ def process_download_requests():
                 # Download each file and verify the sum
                 try:
                     for i in range(len(files)):
- print "%s: downloading %s" % (relfile, files[i])
- dest_file = urllib.urlretrieve(files[i])[0]
+ print("%s: downloading %s" % (relfile, files[i]))
+ dest_file = urllib.request.urlretrieve(files[i])[0]
                         output = subprocess.check_output(["sha256sum", dest_file])
                         output = output.split(' ')[0]
                         if output == sums[i]:

I hope that Launchpad is just slow here.

716. By Brian Murray

merge with upstream

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/apt_check.py'
--- data/apt_check.py 2012-06-12 09:09:32 +0000
+++ data/apt_check.py 2012-06-14 22:18:20 +0000
@@ -1,5 +1,6 @@
1#!/usr/bin/python1#!/usr/bin/python3
22
3from __future__ import print_function
34
4#nice apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst 5#nice apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst
56
@@ -15,27 +16,32 @@
15DISTRO = subprocess.Popen(["lsb_release","-c","-s"],16DISTRO = subprocess.Popen(["lsb_release","-c","-s"],
16 stdout=subprocess.PIPE).communicate()[0].strip()17 stdout=subprocess.PIPE).communicate()[0].strip()
1718
19
18def _(msg):20def _(msg):
19 return gettext.dgettext("update-notifier", msg)21 return gettext.dgettext("update-notifier", msg)
2022
23
21def _handleException(type, value, tb):24def _handleException(type, value, tb):
22 sys.stderr.write("E: "+ _("Unknown Error: '%s' (%s)") % (type,value))25 sys.stderr.write("E: "+ _("Unknown Error: '%s' (%s)") % (type,value))
23 sys.exit(-1)26 sys.exit(-1)
2427
25def clean(cache,depcache):28
29def clean(cache, depcache):
26 " unmark (clean) all changes from the given depcache "30 " unmark (clean) all changes from the given depcache "
27 # mvo: looping is too inefficient with the new auto-mark code31 # mvo: looping is too inefficient with the new auto-mark code
28 #for pkg in cache.Packages:32 #for pkg in cache.Packages:
29 # depcache.MarkKeep(pkg)33 # depcache.MarkKeep(pkg)
30 depcache.init()34 depcache.init()
3135
32def saveDistUpgrade(cache,depcache):36
37def saveDistUpgrade(cache, depcache):
33 """ this functions mimics a upgrade but will never remove anything """38 """ this functions mimics a upgrade but will never remove anything """
34 depcache.upgrade(True)39 depcache.upgrade(True)
35 if depcache.del_count > 0:40 if depcache.del_count > 0:
36 clean(cache,depcache)41 clean(cache, depcache)
37 depcache.upgrade()42 depcache.upgrade()
3843
44
39def isSecurityUpgrade(ver):45def isSecurityUpgrade(ver):
40 " check if the given version is a security update (or masks one) "46 " check if the given version is a security update (or masks one) "
41 security_pockets = [("Ubuntu", "%s-security" % DISTRO),47 security_pockets = [("Ubuntu", "%s-security" % DISTRO),
@@ -48,12 +54,13 @@
48 return True54 return True
49 return False55 return False
5056
57
51def write_package_names(outstream, cache, depcache):58def write_package_names(outstream, cache, depcache):
52 " write out package names that change to outstream "59 " write out package names that change to outstream "
53 pkgs = filter(lambda pkg:60 pkgs = [pkg for pkg in cache.packages if depcache.marked_install(pkg) or
54 depcache.marked_install(pkg) or depcache.marked_upgrade(pkg),61 depcache.marked_upgrade(pkg)]
55 cache.packages)62 outstream.write("\n".join(map([p.name for p in pkgs])))
56 outstream.write("\n".join(map(lambda p: p.name, pkgs)))63
5764
58def write_human_readable_summary(outstream, upgrades, security_updates):65def write_human_readable_summary(outstream, upgrades, security_updates):
59 " write out human summary summary to outstream "66 " write out human summary summary to outstream "
@@ -67,6 +74,8 @@
67 "%i updates are security updates.",74 "%i updates are security updates.",
68 security_updates) % security_updates)75 security_updates) % security_updates)
69 outstream.write("\n")76 outstream.write("\n")
77
78
70def init():79def init():
71 " init the system, be nice "80 " init the system, be nice "
72 # FIXME: do a ionice here too?81 # FIXME: do a ionice here too?
@@ -74,24 +83,25 @@
74 apt_pkg.init()83 apt_pkg.init()
75 # force apt to build its caches in memory for now to make sure84 # force apt to build its caches in memory for now to make sure
76 # that there is no race when the pkgcache file gets re-generated85 # that there is no race when the pkgcache file gets re-generated
77 apt_pkg.config.set("Dir::Cache::pkgcache","")86 apt_pkg.config.set("Dir::Cache::pkgcache", "")
78 87
88
79def run(options=None):89def run(options=None):
8090
81 # we are run in "are security updates installed automatically?"91 # we are run in "are security updates installed automatically?"
82 # question mode92 # question mode
83 if options.security_updates_unattended:93 if options.security_updates_unattended:
84 res = apt_pkg.config.find_i("APT::Periodic::Unattended-Upgrade", 0)94 res = apt_pkg.config.find_i("APT::Periodic::Unattended-Upgrade", 0)
85 #print res95 #print(res)
86 sys.exit(res)96 sys.exit(res)
8797
88 # get caches98 # get caches
89 try:99 try:
90 cache = apt_pkg.Cache(apt.progress.base.OpProgress())100 cache = apt_pkg.Cache(apt.progress.base.OpProgress())
91 except SystemError, e:101 except SystemError as e:
92 sys.stderr.write("E: "+ _("Error: Opening the cache (%s)") % e)102 sys.stderr.write("E: "+ _("Error: Opening the cache (%s)") % e)
93 sys.exit(-1)103 sys.exit(-1)
94 depcache = apt_pkg.DepCache(cache)104 depcache = apt_pkg.GetDepCache(cache)
95105
96 # read the pin files106 # read the pin files
97 depcache.read_pinfile()107 depcache.read_pinfile()
@@ -108,8 +118,8 @@
108118
109 # do the upgrade (not dist-upgrade!)119 # do the upgrade (not dist-upgrade!)
110 try:120 try:
111 saveDistUpgrade(cache,depcache)121 saveDistUpgrade(cache, depcache)
112 except SystemError, e:122 except SystemError as e:
113 sys.stderr.write("E: "+ _("Error: Marking the upgrade (%s)") % e)123 sys.stderr.write("E: "+ _("Error: Marking the upgrade (%s)") % e)
114 sys.exit(-1)124 sys.exit(-1)
115125
@@ -128,16 +138,16 @@
128 continue138 continue
129139
130 # check for security upgrades140 # check for security upgrades
131 upgrades = upgrades + 1 141 upgrades = upgrades + 1
132 if isSecurityUpgrade(cand_ver):142 if isSecurityUpgrade(cand_ver):
133 security_updates += 1143 security_updates += 1
134 continue144 continue
135145
136 # now check for security updates that are masked by a 146 # now check for security updates that are masked by a
137 # canidate version from another repo (-proposed or -updates)147 # canidate version from another repo (-proposed or -updates)
138 for ver in pkg.version_list:148 for ver in pkg.version_list:
139 if (inst_ver and apt_pkg.version_compare(ver.ver_str, inst_ver.ver_str) <= 0):149 if (inst_ver and apt_pkg.version_compare(ver.ver_str, inst_ver.ver_str) <= 0):
140 #print "skipping '%s' " % ver.VerStr150 #print("skipping '%s' " % ver.VerStr)
141 continue151 continue
142 if isSecurityUpgrade(ver):152 if isSecurityUpgrade(ver):
143 security_updates += 1153 security_updates += 1
@@ -149,19 +159,19 @@
149 elif options and options.readable_output:159 elif options and options.readable_output:
150 write_human_readable_summary(sys.stdout, upgrades, security_updates)160 write_human_readable_summary(sys.stdout, upgrades, security_updates)
151 else:161 else:
152 # print the number of regular upgrades and the number of 162 # print the number of regular upgrades and the number of
153 # security upgrades163 # security upgrades
154 sys.stderr.write("%s;%s" % (upgrades,security_updates))164 sys.stderr.write("%s;%s" % (upgrades, security_updates))
155165
156 # return the number of upgrades (if its used as a module)166 # return the number of upgrades (if its used as a module)
157 return(upgrades,security_updates)167 return(upgrades, security_updates)
158168
159169
160if __name__ == "__main__": 170if __name__ == "__main__":
161 # setup a exception handler to make sure that uncaught stuff goes171 # setup a exception handler to make sure that uncaught stuff goes
162 # to the notifier172 # to the notifier
163 sys.excepthook = _handleException173 sys.excepthook = _handleException
164 174
165 # gettext175 # gettext
166 APP="update-notifier"176 APP="update-notifier"
167 DIR="/usr/share/locale"177 DIR="/usr/share/locale"
168178
=== modified file 'data/backend_helper.py'
--- data/backend_helper.py 2011-08-10 13:54:37 +0000
+++ data/backend_helper.py 2012-06-14 22:18:20 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
22
3import argparse3import argparse
4import dbus4import dbus
@@ -8,8 +8,8 @@
8import sys8import sys
99
10GKSU = ["/usr/bin/gksu"]10GKSU = ["/usr/bin/gksu"]
11SYNPATIC_DESKTOP = ["--desktop", 11SYNAPTIC_DESKTOP = ["--desktop",
12 "/usr/share/applications/synaptic.desktop", 12 "/usr/share/applications/synaptic.desktop",
13 "--"]13 "--"]
14HAVE_APTDAEMON = False14HAVE_APTDAEMON = False
15try:15try:
@@ -18,6 +18,7 @@
18except ImportError:18except ImportError:
19 pass19 pass
2020
21
21# show updates22# show updates
22def show_updates():23def show_updates():
23 """ show updates using update-manager """24 """ show updates using update-manager """
@@ -38,9 +39,10 @@
38 dia.run()39 dia.run()
39 Gtk.main()40 Gtk.main()
40 return trans.exit == enums.EXIT_SUCCESS41 return trans.exit == enums.EXIT_SUCCESS
41 42
43
42def _install_all_updates_gksu():44def _install_all_updates_gksu():
43 cmd = GKSU + SYNPATIC_DESKTOP + [ "/usr/sbin/synaptic ",45 cmd = GKSU + SYNAPTIC_DESKTOP + ["/usr/sbin/synaptic ",
44 "--dist-upgrade-mode",46 "--dist-upgrade-mode",
45 "--non-interactive",47 "--non-interactive",
46 "--hide-main-window",48 "--hide-main-window",
@@ -48,6 +50,7 @@
48 ]50 ]
49 return subprocess.call(cmd)51 return subprocess.call(cmd)
5052
53
51def install_all_updates():54def install_all_updates():
52 """ install all updates either with synaptic or aptdaemon """55 """ install all updates either with synaptic or aptdaemon """
53 if HAVE_APTDAEMON:56 if HAVE_APTDAEMON:
@@ -69,14 +72,16 @@
69 Gtk.main()72 Gtk.main()
70 return trans.exit == enums.EXIT_SUCCESS73 return trans.exit == enums.EXIT_SUCCESS
7174
75
72def _check_updates_gtk():76def _check_updates_gtk():
73 cmd = GKSU + SYNPATIC_DESKTOP + ["/usr/sbin/synaptic",77 cmd = GKSU + SYNAPTIC_DESKTOP + ["/usr/sbin/synaptic",
74 "--update-at-startup",78 "--update-at-startup",
75 "--non-interactive",79 "--non-interactive",
76 "--hide-main-window",80 "--hide-main-window",
77 ]81 ]
78 subprocess.call(cmd)82 subprocess.call(cmd)
7983
84
80def check_updates():85def check_updates():
81 """ check for updates either with aptdaemon or synaptic """86 """ check for updates either with aptdaemon or synaptic """
82 if HAVE_APTDAEMON:87 if HAVE_APTDAEMON:
@@ -88,7 +93,7 @@
88# start packagemanager93# start packagemanager
89def start_packagemanager():94def start_packagemanager():
90 if os.path.exists("/usr/sbin/synaptic"):95 if os.path.exists("/usr/sbin/synaptic"):
91 cmd = GKSU + SYNPATIC_DESKTOP + ["/usr/sbin/synaptic"]96 cmd = GKSU + SYNAPTIC_DESKTOP + ["/usr/sbin/synaptic"]
92 return subprocess.call(cmd)97 return subprocess.call(cmd)
93 elif os.path.exists("/usr/bin/software-center"):98 elif os.path.exists("/usr/bin/software-center"):
94 return subprocess.call(["/usr/bin/software-center"])99 return subprocess.call(["/usr/bin/software-center"])
@@ -111,18 +116,17 @@
111 if os.path.exists("/usr/bin/software-center"):116 if os.path.exists("/usr/bin/software-center"):
112 subprocess.call(["/usr/bin/software-center"])117 subprocess.call(["/usr/bin/software-center"])
113118
119
114def _add_cdrom_synaptic(mount_path):120def _add_cdrom_synaptic(mount_path):
115 cmd = GKSU + SYNPATIC_DESKTOP + ["synaptic", "--add-cdrom", mount_path]121 cmd = GKSU + SYNAPTIC_DESKTOP + ["synaptic", "--add-cdrom", mount_path]
116 return subprocess.call(cmd)122 return subprocess.call(cmd)
117123
124
118def add_cdrom(mount_path):125def add_cdrom(mount_path):
119 if os.path.exists("/usr/sbin/synaptic"):126 if os.path.exists("/usr/sbin/synaptic"):
120 _add_cdrom_synaptic(mount_path)127 _add_cdrom_synaptic(mount_path)
121 else:128 else:
122 _add_cdrom_sp(mount_path)129 _add_cdrom_sp(mount_path)
123
124
125
126130
127131
128if __name__ == "__main__":132if __name__ == "__main__":
@@ -149,7 +153,7 @@
149 command = subparser.add_parser("add_cdrom")153 command = subparser.add_parser("add_cdrom")
150 command.add_argument("mount_path")154 command.add_argument("mount_path")
151 command.set_defaults(command="add_cdrom")155 command.set_defaults(command="add_cdrom")
152 156
153 args = parser.parse_args()157 args = parser.parse_args()
154 if args.debug:158 if args.debug:
155 logging.basicConfig(level=logging.DEBUG)159 logging.basicConfig(level=logging.DEBUG)
@@ -159,10 +163,9 @@
159 func_name = args.command163 func_name = args.command
160 f_kwargs = {}164 f_kwargs = {}
161 f = globals()[func_name]165 f = globals()[func_name]
162 if args.command == "add_cdrom":166 if args.command == "add_cdrom":
163 f_kwargs["mount_path"] = args.mount_path167 f_kwargs["mount_path"] = args.mount_path
164 res = f(**f_kwargs)168 res = f(**f_kwargs)
165169
166 if not res:170 if not res:
167 sys.exit(1)171 sys.exit(1)
168
169172
=== modified file 'data/hooks.py'
--- data/hooks.py 2010-08-23 08:58:54 +0000
+++ data/hooks.py 2012-06-14 22:18:20 +0000
@@ -1,19 +1,26 @@
1#!/usr/bin/python2.41#!/usr/bin/python3
2
3from __future__ import print_function
24
3from optparse import OptionParser5from optparse import OptionParser
4import user, string, dircache, sys, os.path6
57import dircache
6 8import os.path
9import string
10import sys
11import user
12
13
7class HookFiles(object):14class HookFiles(object):
8 """ represents all hook files """15 """ represents all hook files """
916
10 # the hooks are stored here17 # the hooks are stored here
11 hookDir = "/var/lib/update-notifier/user.d/"18 hookDir = "/var/lib/update-notifier/user.d/"
12 19
13 class HookFile(object):20 class HookFile(object):
14 """ represents a single hook file """21 """ represents a single hook file """
15 __slots__ = [ "filename", "mtime", "cmd_run", "seen" ]22 __slots__ = ["filename", "mtime", "cmd_run", "seen"]
16 23
17 def __init__(self, filename):24 def __init__(self, filename):
18 self.filename = filename25 self.filename = filename
19 self.mtime = os.stat(HookFiles.hookDir+filename).st_mtime26 self.mtime = os.stat(HookFiles.hookDir+filename).st_mtime
@@ -24,17 +31,16 @@
24 """ show the summary for the notification """31 """ show the summary for the notification """
25 # FIXME: read rfc822 style file and get the i18n version of32 # FIXME: read rfc822 style file and get the i18n version of
26 # "Name"33 # "Name"
27 pass34 pass
28 summary = property(summary)35 summary = property(summary)
2936
30 def description(self):37 def description(self):
31 """ show a long description for the notification """38 """ show a long description for the notification """
32 # FIXME: read rfc822 style file and get the i18n version of39 # FIXME: read rfc822 style file and get the i18n version of
33 # "Description", convert "\n" -> " " and strstrip it afterwards40 # "Description", convert "\n" -> " " and strstrip it afterwards
34 pass41 pass
35 description = property(description)42 description = property(description)
3643
37
38 def __init__(self):44 def __init__(self):
39 self._hooks = {}45 self._hooks = {}
40 self._readSeenFile()46 self._readSeenFile()
@@ -49,25 +55,25 @@
49 if os.path.exists(hooks_seen):55 if os.path.exists(hooks_seen):
50 for line in open(hooks_seen):56 for line in open(hooks_seen):
51 filename, mtime, cmd_run = string.split(line)57 filename, mtime, cmd_run = string.split(line)
52 if os.path.exists(self.hookDir+filename) and \58 if os.path.exists(self.hookDir + filename) and \
53 not self._hooks.has_key(filename):59 not filename in self._hooks:
54 h = self.HookFile(filename)60 h = self.HookFile(filename)
55 h.mtime = mtime61 h.mtime = mtime
56 h.cmd_run = cmd_run62 h.cmd_run = cmd_run
57 h.seen = True63 h.seen = True
58 # check if file was motified since we last saw it64 # check if file was motified since we last saw it
59 if os.stat(self.hookDir+filename).st_mtime > int(mtime):65 if os.stat(self.hookDir + filename).st_mtime > int(mtime):
60 h.seen = False66 h.seen = False
61 self._hooks[filename] = h67 self._hooks[filename] = h
6268
63 def _update(self):69 def _update(self):
64 """ update hook dict with the current state on the fs """70 """ update hook dict with the current state on the fs """
65 for hook in dircache.listdir(self.hookDir):71 for hook in dircache.listdir(self.hookDir):
66 if self._hooks.has_key(hook):72 if hook in self._hooks:
67 # we have it already, check if it was motified since73 # we have it already, check if it was motified since
68 # we last saw it74 # we last saw it
69 h = self._hooks[hook]75 h = self._hooks[hook]
70 if os.stat(self.hookDir+hook).st_mtime > int(h.mtime):76 if os.stat(self.hookDir + hook).st_mtime > int(h.mtime):
71 h.seen = False77 h.seen = False
72 else:78 else:
73 self._hooks[hook] = self.HookFile(hook)79 self._hooks[hook] = self.HookFile(hook)
@@ -80,19 +86,20 @@
80 if not self._hooks[hook].seen:86 if not self._hooks[hook].seen:
81 new.append(self._hooks[hook])87 new.append(self._hooks[hook])
82 return new88 return new
83 89
8490
85def check():91def check():
86 hooks = HookFiles()92 hooks = HookFiles()
87 new = hooks.checkNew()93 new = hooks.checkNew()
88 return len(new)94 return len(new)
8995
96
90def test():97def test():
91 hooks = HookFiles()98 hooks = HookFiles()
92 new = hooks.checkNew()99 new = hooks.checkNew()
93 print "Hooks: %s" % len(new)100 print("Hooks: %s" % len(new))
94 for hook in hooks._hooks:101 for hook in hooks._hooks:
95 print hooks._hooks[hook].notification102 print(hooks._hooks[hook].notification)
96103
97104
98if __name__ == "__main__":105if __name__ == "__main__":
@@ -105,7 +112,6 @@
105 default=False, help="run test")112 default=False, help="run test")
106 (options, args) = parser.parse_args()113 (options, args) = parser.parse_args()
107114
108
109 if options.check:115 if options.check:
110 sys.exit(check())116 sys.exit(check())
111 elif options.run:117 elif options.run:
112118
=== modified file 'data/package-data-downloader'
--- data/package-data-downloader 2012-06-13 22:49:33 +0000
+++ data/package-data-downloader 2012-06-14 22:18:20 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3"""Process new requests to download per-package data"""3"""Process new requests to download per-package data"""
4# Copyright (C) 2012 Canonical Ltd4# Copyright (C) 2012 Canonical Ltd
@@ -16,13 +16,15 @@
16# with this program; if not, write to the Free Software Foundation, Inc.,16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818
19from __future__ import print_function
20
19import glob21import glob
20import os22import os
21import sys23import sys
22import subprocess24import subprocess
23import re25import re
24import traceback26import traceback
25import urllib27import urllib.request
26import debian.deb82228import debian.deb822
27import string29import string
28import apt30import apt
@@ -184,7 +186,7 @@
184 pass186 pass
185187
186 if proxies:188 if proxies:
187 urllib._urlopener = urllib.FancyURLopener(proxies)189 urllib.request._urlopener = urllib.request.FancyURLopener(proxies)
188 except Exception:190 except Exception:
189 pass191 pass
190192
@@ -209,13 +211,13 @@
209 files = []211 files = []
210 sums = []212 sums = []
211 for para in hook.iter_paragraphs(open(file)):213 for para in hook.iter_paragraphs(open(file)):
212 if para.has_key('script'):214 if 'script' in para:
213 if not files:215 if not files:
214 record_failure(relfile)216 record_failure(relfile)
215 break217 break
216 command = [para['script']]218 command = [para['script']]
217219
218 if para.has_key('should-download'):220 if 'should-download' in para:
219 db = debconf.DebconfCommunicator('update-notifier')221 db = debconf.DebconfCommunicator('update-notifier')
220 try:222 try:
221 should = db.get(para['should-download'])223 should = db.get(para['should-download'])
@@ -230,8 +232,8 @@
230 # Download each file and verify the sum232 # Download each file and verify the sum
231 try:233 try:
232 for i in range(len(files)):234 for i in range(len(files)):
233 print "%s: downloading %s" % (relfile, files[i])235 print("%s: downloading %s" % (relfile, files[i]))
234 dest_file = urllib.urlretrieve(files[i])[0]236 dest_file = urllib.request.urlretrieve(files[i])[0]
235 output = subprocess.check_output(["sha256sum", dest_file])237 output = subprocess.check_output(["sha256sum", dest_file])
236 output = output.split(' ')[0]238 output = output.split(' ')[0]
237 if output == sums[i]:239 if output == sums[i]:
238240
=== modified file 'debian/changelog'
--- debian/changelog 2012-06-12 09:12:28 +0000
+++ debian/changelog 2012-06-14 22:18:20 +0000
@@ -1,3 +1,12 @@
1update-notifier (0.119ubuntu14) UNRELEASED; urgency=low
2
3 * Port to Python 3
4 - Use the new python-apt API since the legacy API is not available
5 in Python 3.
6 - Various and pyflakes, whitespace, style, line length fixes.
7
8 -- Brian Murray <brian@ubuntu.com> Tue, 12 Jun 2012 08:35:48 -0700
9
1update-notifier (0.119ubuntu13) quantal; urgency=low10update-notifier (0.119ubuntu13) quantal; urgency=low
211
3 * data/apt_check.py:12 * data/apt_check.py:
413
=== modified file 'debian/control'
--- debian/control 2012-05-14 22:31:36 +0000
+++ debian/control 2012-06-14 22:18:20 +0000
@@ -12,25 +12,27 @@
12 libx11-dev,12 libx11-dev,
13 autotools-dev,13 autotools-dev,
14 libappindicator3-dev,14 libappindicator3-dev,
15 po-debconf15 po-debconf,
16 python3
16Standards-Version: 3.8.417Standards-Version: 3.8.4
17Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/update-notifier/ubuntu18Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/update-notifier/ubuntu
19X-Python3-Version: >= 3.2
1820
19Package: update-notifier21Package: update-notifier
20Architecture: any22Architecture: any
21Depends: ${shlibs:Depends},23Depends: ${shlibs:Depends},
22 ${misc:Depends},24 ${misc:Depends},
23 update-notifier-common (= ${source:Version}),25 update-notifier-common (= ${source:Version}),
24 python,26 python3,
25 python-dbus,27 python3-dbus,
26 update-manager-gnome | update-manager,28 update-manager-gnome | update-manager,
27 notification-daemon,29 notification-daemon,
28 gksu30 gksu
29Recommends: apport-gtk, 31Recommends: apport-gtk,
30 python-aptdaemon.gtk3widgets | synaptic, 32 python3-aptdaemon.gtk3widgets | synaptic,
31 software-properties-gtk, 33 software-properties-gtk,
32 anacron, 34 anacron,
33 aptdaemon35 python3-aptdaemon
34Suggests: ubuntu-system-service36Suggests: ubuntu-system-service
35Description: Daemon which notifies about package updates37Description: Daemon which notifies about package updates
36 Puts an icon in the user's notification area when package updates are38 Puts an icon in the user's notification area when package updates are
@@ -42,8 +44,8 @@
42Pre-Depends: dpkg (>= 1.15.7.2)44Pre-Depends: dpkg (>= 1.15.7.2)
43Depends: ${shlibs:Depends},45Depends: ${shlibs:Depends},
44 ${misc:Depends},46 ${misc:Depends},
45 python,47 python3,
46 python-apt (>= 0.6.12), python-debian, debconf48 python3-apt (>= 0.6.12), python3-debian, debconf
47Recommends: libpam-modules (>= 1.0.1-9ubuntu3)49Recommends: libpam-modules (>= 1.0.1-9ubuntu3)
48Suggests: gksu50Suggests: gksu
49Description: Files shared between update-notifier and other packages51Description: Files shared between update-notifier and other packages
5052
=== modified file 'debian/rules'
--- debian/rules 2010-06-01 13:28:36 +0000
+++ debian/rules 2012-06-14 22:18:20 +0000
@@ -3,4 +3,4 @@
3export LDFLAGS += -Wl,-z,defs -Wl,-O1 -Wl,--as-needed3export LDFLAGS += -Wl,-z,defs -Wl,-O1 -Wl,--as-needed
44
5%:5%:
6 dh $@6 dh $@ --with python3
77
=== modified file 'tests/test_package-data-downloader.py'
--- tests/test_package-data-downloader.py 2012-03-23 09:11:45 +0000
+++ tests/test_package-data-downloader.py 2012-06-14 22:18:20 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
22
3import os3import os
4import shutil4import shutil

Subscribers

People subscribed via source and target branches

to all changes: