Merge lp:~barry/software-center/lp1526450 into lp:software-center

Proposed by Barry Warsaw
Status: Merged
Approved by: dobey
Approved revision: 3326
Merged at revision: 3334
Proposed branch: lp:~barry/software-center/lp1526450
Merge into: lp:software-center
Diff against target: 305 lines (+50/-31)
10 files modified
softwarecenter/backend/scagent.py (+3/-1)
softwarecenter/backend/spawn_helper.py (+4/-2)
softwarecenter/backend/ubuntusso.py (+9/-7)
softwarecenter/config.py (+5/-3)
softwarecenter/db/__init__.py (+3/-1)
softwarecenter/db/database.py (+1/-2)
softwarecenter/db/update.py (+6/-1)
softwarecenter/distro/__init__.py (+3/-1)
softwarecenter/distro/ubuntu.py (+6/-5)
softwarecenter/utils.py (+10/-8)
To merge this branch: bzr merge lp:~barry/software-center/lp1526450
Reviewer Review Type Date Requested Status
dobey Approve
Iain Lane (community) Approve
Sebastien Bacher Pending
Review via email: mp+280656@code.launchpad.net

Description of the change

Restores some bilingual Python 2/3 constructs so that plugins can run in the Python 3 ported apt-xapian-index and still run in Python 2.7 software-center.

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :

Looks good to me, thanks

I see some extra changes on '2to3 update.py' that might be worth looking into.

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/backend/scagent.py'
--- softwarecenter/backend/scagent.py 2012-12-14 16:44:25 +0000
+++ softwarecenter/backend/scagent.py 2015-12-15 23:10:41 +0000
@@ -19,11 +19,13 @@
19# this program; if not, write to the Free Software Foundation, Inc.,19# this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121
22from __future__ import absolute_import
23
22from gi.repository import GObject24from gi.repository import GObject
23import logging25import logging
2426
25import softwarecenter.paths27import softwarecenter.paths
26from spawn_helper import SpawnHelper28from .spawn_helper import SpawnHelper
27from softwarecenter.i18n import get_language29from softwarecenter.i18n import get_language
28from softwarecenter.distro import get_distro, get_current_arch30from softwarecenter.distro import get_distro, get_current_arch
2931
3032
=== modified file 'softwarecenter/backend/spawn_helper.py'
--- softwarecenter/backend/spawn_helper.py 2013-02-06 23:38:21 +0000
+++ softwarecenter/backend/spawn_helper.py 2015-12-15 23:10:41 +0000
@@ -109,7 +109,8 @@
109 stdout, GLib.PRIORITY_DEFAULT, GObject.IO_IN,109 stdout, GLib.PRIORITY_DEFAULT, GObject.IO_IN,
110 self._helper_io_ready, (stdout, ))110 self._helper_io_ready, (stdout, ))
111111
112 def _helper_finished(self, pid, status, (stdout, stderr)):112 def _helper_finished(self, pid, status, stdio_tuple):
113 stdout, stderr = stdio_tuple
113 LOG.debug("helper_finished: '%s' '%s'" % (pid, status))114 LOG.debug("helper_finished: '%s' '%s'" % (pid, status))
114 # get status code115 # get status code
115 res = os.WEXITSTATUS(status)116 res = os.WEXITSTATUS(status)
@@ -131,7 +132,8 @@
131 if self._child_watch:132 if self._child_watch:
132 GLib.source_remove(self._child_watch)133 GLib.source_remove(self._child_watch)
133134
134 def _helper_io_ready(self, source, condition, (stdout,)):135 def _helper_io_ready(self, source, condition, stdio_tuple):
136 stdout, = stdio_tuple
135 # read the raw data137 # read the raw data
136 data = ""138 data = ""
137 while True:139 while True:
138140
=== modified file 'softwarecenter/backend/ubuntusso.py'
--- softwarecenter/backend/ubuntusso.py 2012-12-06 16:16:49 +0000
+++ softwarecenter/backend/ubuntusso.py 2015-12-15 23:10:41 +0000
@@ -20,6 +20,8 @@
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121
2222
23from __future__ import absolute_import, print_function
24
23from gi.repository import GObject, GLib25from gi.repository import GObject, GLib
24from gettext import gettext as _26from gettext import gettext as _
2527
@@ -33,8 +35,8 @@
33import softwarecenter.paths35import softwarecenter.paths
3436
35# mostly for testing37# mostly for testing
36from fake_review_settings import FakeReviewSettings, network_delay38from .fake_review_settings import FakeReviewSettings, network_delay
37from spawn_helper import SpawnHelper39from .spawn_helper import SpawnHelper
38from softwarecenter.config import get_config40from softwarecenter.config import get_config
39from softwarecenter.backend.login import get_login_backend41from softwarecenter.backend.login import get_login_backend
4042
@@ -215,11 +217,11 @@
215217
216# test code218# test code
217def _login_success(lp, token):219def _login_success(lp, token):
218 print "success", lp, token220 print("success", lp, token)
219221
220222
221def _login_failed(lp):223def _login_failed(lp):
222 print "fail", lp224 print("fail", lp)
223225
224226
225def _login_need_user_and_password(sso):227def _login_need_user_and_password(sso):
@@ -236,15 +238,15 @@
236# interactive test code238# interactive test code
237if __name__ == "__main__":239if __name__ == "__main__":
238 def _whoami(sso, result):240 def _whoami(sso, result):
239 print "res: ", result241 print("res: ", result)
240 Gtk.main_quit()242 Gtk.main_quit()
241243
242 def _error(sso, result):244 def _error(sso, result):
243 print "err: ", result245 print("err: ", result)
244 Gtk.main_quit()246 Gtk.main_quit()
245247
246 def _dbus_maybe_login_successful(ssologin, oauth_result):248 def _dbus_maybe_login_successful(ssologin, oauth_result):
247 print "got token, verify it now"249 print("got token, verify it now")
248 sso = UbuntuSSO()250 sso = UbuntuSSO()
249 sso.connect("whoami", _whoami)251 sso.connect("whoami", _whoami)
250 sso.connect("error", _error)252 sso.connect("error", _error)
251253
=== modified file 'softwarecenter/config.py'
--- softwarecenter/config.py 2013-07-09 14:33:47 +0000
+++ softwarecenter/config.py 2015-12-15 23:10:41 +0000
@@ -16,6 +16,8 @@
16# this program; if not, write to the Free Software Foundation, Inc.,16# this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
19from __future__ import absolute_import
20
19# py3 compat21# py3 compat
20try:22try:
21 from configparser import SafeConfigParser23 from configparser import SafeConfigParser
@@ -25,7 +27,7 @@
25import os27import os
26import logging28import logging
2729
28from paths import SOFTWARE_CENTER_CONFIG_FILE30from .paths import SOFTWARE_CENTER_CONFIG_FILE
2931
30LOG = logging.getLogger(__name__)32LOG = logging.getLogger(__name__)
3133
@@ -37,7 +39,7 @@
37 def __init__(self, config):39 def __init__(self, config):
38 SafeConfigParser.__init__(self)40 SafeConfigParser.__init__(self)
39 # imported here to avoid cycle41 # imported here to avoid cycle
40 from utils import safe_makedirs42 from .utils import safe_makedirs
41 safe_makedirs(os.path.dirname(config))43 safe_makedirs(os.path.dirname(config))
42 # we always want this sections, even on fresh installs44 # we always want this sections, even on fresh installs
43 for section in self.SECTIONS:45 for section in self.SECTIONS:
@@ -57,7 +59,7 @@
57 tmpname = self.configfile + ".new"59 tmpname = self.configfile + ".new"
58 # see LP: #996333, its ok to remove the old configfile as60 # see LP: #996333, its ok to remove the old configfile as
59 # its rewritten anyway61 # its rewritten anyway
60 from utils import ensure_file_writable_and_delete_if_not62 from .utils import ensure_file_writable_and_delete_if_not
61 ensure_file_writable_and_delete_if_not(tmpname)63 ensure_file_writable_and_delete_if_not(tmpname)
62 ensure_file_writable_and_delete_if_not(self.configfile)64 ensure_file_writable_and_delete_if_not(self.configfile)
63 try:65 try:
6466
=== modified file 'softwarecenter/db/__init__.py'
--- softwarecenter/db/__init__.py 2012-05-16 15:52:07 +0000
+++ softwarecenter/db/__init__.py 2015-12-15 23:10:41 +0000
@@ -1,7 +1,9 @@
1from __future__ import absolute_import
2
1import logging3import logging
24
3try:5try:
4 from debfile import DebFileApplication, DebFileOpenError6 from .debfile import DebFileApplication, DebFileOpenError
5 DebFileApplication # pyflakes7 DebFileApplication # pyflakes
6 DebFileOpenError # pyflakes8 DebFileOpenError # pyflakes
7except:9except:
810
=== modified file 'softwarecenter/db/database.py'
--- softwarecenter/db/database.py 2013-09-17 17:10:03 +0000
+++ softwarecenter/db/database.py 2015-12-15 23:10:41 +0000
@@ -20,7 +20,6 @@
20import logging20import logging
21import os21import os
22import re22import re
23import string
24import threading23import threading
25import xapian24import xapian
26from softwarecenter.db.application import Application25from softwarecenter.db.application import Application
@@ -62,7 +61,7 @@
62 if not os.path.exists(filename):61 if not os.path.exists(filename):
63 return axi_values62 return axi_values
64 for raw_line in open(filename):63 for raw_line in open(filename):
65 line = string.split(raw_line, "#", 1)[0]64 line = raw_line.split("#", 1)[0]
66 if line.strip() == "":65 if line.strip() == "":
67 continue66 continue
68 (key, value) = line.split()67 (key, value) = line.split()
6968
=== modified file 'softwarecenter/db/update.py'
--- softwarecenter/db/update.py 2015-01-11 23:33:51 +0000
+++ softwarecenter/db/update.py 2015-12-15 23:10:41 +0000
@@ -54,7 +54,12 @@
5454
5555
56from glob import glob56from glob import glob
57from urlparse import urlparse57
58# py3 compat
59try:
60 from urlparse import urlparse
61except ImportError:
62 from urllib.parse import urlparse
5863
59import softwarecenter.paths64import softwarecenter.paths
6065
6166
=== modified file 'softwarecenter/distro/__init__.py'
--- softwarecenter/distro/__init__.py 2013-11-25 21:58:02 +0000
+++ softwarecenter/distro/__init__.py 2015-12-15 23:10:41 +0000
@@ -19,6 +19,7 @@
1919
20import logging20import logging
21import os21import os
22import sys
2223
23from gettext import gettext as _24from gettext import gettext as _
24import platform25import platform
@@ -171,7 +172,8 @@
171 distro_module_name = distro_id.lower()172 distro_module_name = distro_id.lower()
172 distro_class_name = distro_id.capitalize()173 distro_class_name = distro_id.capitalize()
173 # start with a import, this gives us only a softwarecenter module174 # start with a import, this gives us only a softwarecenter module
174 module = __import__(distro_module_name, globals(), locals(), [], -1)175 level = (-1 if sys.version_info < (3,) else 1)
176 module = __import__(distro_module_name, globals(), locals(), [], level)
175 # get the right class and instantiate it177 # get the right class and instantiate it
176 distro_class = getattr(module, distro_class_name)178 distro_class = getattr(module, distro_class_name)
177 instance = distro_class()179 instance = distro_class()
178180
=== modified file 'softwarecenter/distro/ubuntu.py'
--- softwarecenter/distro/ubuntu.py 2015-01-11 23:33:51 +0000
+++ softwarecenter/distro/ubuntu.py 2015-12-15 23:10:41 +0000
@@ -14,11 +14,12 @@
14# this program; if not, write to the Free Software Foundation, Inc.,14# this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1616
17from __future__ import print_function
18
17import datetime19import datetime
18import locale20import locale
19import logging21import logging
20import os22import os
21import re
2223
23from apt.utils import (get_release_filename_for_pkg,24from apt.utils import (get_release_filename_for_pkg,
24 get_release_date_from_release_file,25 get_release_date_from_release_file,
@@ -270,7 +271,7 @@
270if __name__ == "__main__":271if __name__ == "__main__":
271 import apt272 import apt
272 cache = apt.Cache()273 cache = apt.Cache()
273 print cache.get_maintenance_status(cache, "synaptic app", "synaptic",274 print(cache.get_maintenance_status(cache, "synaptic app", "synaptic",
274 "main", None)275 "main", None))
275 print cache.get_maintenance_status(cache, "3dchess app", "3dchess",276 print(cache.get_maintenance_status(cache, "3dchess app", "3dchess",
276 "universe", None)277 "universe", None))
277278
=== modified file 'softwarecenter/utils.py'
--- softwarecenter/utils.py 2013-09-06 13:22:03 +0000
+++ softwarecenter/utils.py 2015-12-15 23:10:41 +0000
@@ -16,6 +16,8 @@
16# this program; if not, write to the Free Software Foundation, Inc.,16# this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
19from __future__ import absolute_import, print_function
20
19import dbus21import dbus
20import gc22import gc
21import gettext23import gettext
@@ -39,13 +41,13 @@
39except ImportError:41except ImportError:
40 from urlparse import urlsplit42 from urlparse import urlsplit
4143
42from enums import Icons, APP_INSTALL_PATH_DELIMITER44from .enums import Icons, APP_INSTALL_PATH_DELIMITER
43from paths import (45from .paths import (
44 SOFTWARE_CENTER_CACHE_DIR,46 SOFTWARE_CENTER_CACHE_DIR,
45 OEM_CHANNEL_DESCRIPTOR,47 OEM_CHANNEL_DESCRIPTOR,
46)48)
4749
48from config import get_config50from .config import get_config
4951
50from gettext import gettext as _52from gettext import gettext as _
5153
@@ -115,11 +117,11 @@
115 if not type(obj) in new_obj_types:117 if not type(obj) in new_obj_types:
116 new_obj_types[type(obj)] = 0118 new_obj_types[type(obj)] = 0
117 new_obj_types[type(obj)] += 1119 new_obj_types[type(obj)] += 1
118 print "+++ new types after '%s':" % self.info120 print("+++ new types after '%s':" % self.info)
119 #print new_obj_types121 #print new_obj_types
120 for v in sorted(new_obj_types, key=new_obj_types.get):122 for v in sorted(new_obj_types, key=new_obj_types.get):
121 print v, new_obj_types[v]123 print(v, new_obj_types[v])
122 print "/+++\n"124 print("/+++\n")
123125
124126
125class TraceMemoryUsage(object):127class TraceMemoryUsage(object):
@@ -135,12 +137,12 @@
135 def __exit__(self, atype, value, stack):137 def __exit__(self, atype, value, stack):
136 now_resident = self._get_mem_from_proc()["resident"] - self.resident138 now_resident = self._get_mem_from_proc()["resident"] - self.resident
137 now_data = self._get_mem_from_proc()["data"] - self.data139 now_data = self._get_mem_from_proc()["data"] - self.data
138 print "++++ MEMORY DELTA for '%s': res: %s data: %s (%s %s)\n" % (140 print("++++ MEMORY DELTA for '%s': res: %s data: %s (%s %s)\n" % (
139 self.info,141 self.info,
140 # assume page size of 4k here142 # assume page size of 4k here
141 get_nice_size(now_resident * 4 * 1024),143 get_nice_size(now_resident * 4 * 1024),
142 get_nice_size(now_data * 4 * 1024),144 get_nice_size(now_data * 4 * 1024),
143 now_resident, now_data)145 now_resident, now_data))
144146
145 def _get_mem_from_proc(self):147 def _get_mem_from_proc(self):
146 with open("/proc/%i/statm" % os.getpid()) as f:148 with open("/proc/%i/statm" % os.getpid()) as f: