Merge lp:~mvo/software-center/misc-fixes into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2869
Proposed branch: lp:~mvo/software-center/misc-fixes
Merge into: lp:software-center
Diff against target: 171 lines (+78/-42)
4 files modified
softwarecenter/backend/installbackend_impl/aptd.py (+35/-15)
softwarecenter/ui/gtk3/app.py (+12/-5)
softwarecenter/utils.py (+26/-21)
utils/update-software-center-agent (+5/-1)
To merge this branch: bzr merge lp:~mvo/software-center/misc-fixes
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+97890@code.launchpad.net

Description of the change

Thsis branch adds three fixes:

message:
  softwarecenter/backend/installbackend_impl/aptd.py: when a package can not be authenticated, do not fail (hard) but instead offer to "repair" the situation using a "reload" and try the install again (LP: #876278)

message:
  do not crash in if os.makedirs has a race condition (LP: #956680)

message:
  this fixes the proxy handling with 12.04 as the "enabled" property is deprecated now. it will also not mess with the proxy environment on non-gnome systems (LP: #742564)

To post a comment you must log in.
lp:~mvo/software-center/misc-fixes updated
2870. By Michael Vogt

this fixes the proxy handling with 12.04 as the "enabled" property is deprecated now. it will also not mess with the proxy environment on non-gnome systems (LP: #742564)

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Three fixes in one, nice!! Thanks mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/installbackend_impl/aptd.py'
2--- softwarecenter/backend/installbackend_impl/aptd.py 2012-02-14 16:40:42 +0000
3+++ softwarecenter/backend/installbackend_impl/aptd.py 2012-03-16 17:27:19 +0000
4@@ -766,6 +766,14 @@
5 utf8(alternative_action))
6 return res
7
8+ def _get_app_and_icon_and_deb_from_trans(self, trans):
9+ meta_copy = trans.meta_data.copy()
10+ app = Application(meta_copy.pop("sc_appname", None),
11+ meta_copy.pop("sc_pkgname"))
12+ iconname = meta_copy.pop("sc_iconname", None)
13+ filename = meta_copy.pop("sc_filename", "")
14+ return app, iconname, filename, meta_copy
15+
16 def _on_trans_finished(self, trans, enum):
17 """callback when a aptdaemon transaction finished"""
18 self._logger.debug("_on_transaction_finished: %s %s %s" % (
19@@ -773,21 +781,33 @@
20
21 # show error
22 if enum == enums.EXIT_FAILED:
23- # Handle invalid packages separately
24- if (trans.error and
25- trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE):
26- action = _("_Ignore and install")
27- res = self._show_transaction_failed_dialog(trans, enum, action)
28- if res == "yes":
29- # Reinject the transaction
30- meta_copy = trans.meta_data.copy()
31- app = Application(meta_copy.pop("sc_appname", None),
32- meta_copy.pop("sc_pkgname"))
33- iconname = meta_copy.pop("sc_iconname", None)
34- filename = meta_copy.pop("sc_filename")
35- self.install(app, iconname, filename, [], [],
36- metadata=meta_copy, force=True)
37- return
38+ if trans.error:
39+ # Handle invalid packages separately
40+ if trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE:
41+ action = _("_Ignore and install")
42+ res = self._show_transaction_failed_dialog(
43+ trans, enum, action)
44+ if res == "yes":
45+ # Reinject the transaction
46+ app, iconname, filename, meta_copy = \
47+ self._get_app_and_icon_and_deb_from_trans(trans)
48+ self.install(app, iconname, filename, [], [],
49+ metadata=meta_copy, force=True)
50+ return
51+ # on unauthenticated errors, try a "repair" using the
52+ # reload functionatlity
53+ elif trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED:
54+ action = _("Repair")
55+ res = self._show_transaction_failed_dialog(
56+ trans, enum, action)
57+ if res == "yes":
58+ app, iconname, filename, meta_copy = \
59+ self._get_app_and_icon_and_deb_from_trans(trans)
60+ self.reload()
61+ self.install(app, iconname, filename, [], [],
62+ metadata=meta_copy)
63+ return
64+
65 elif not "sc_add_repo_and_install_ignore_errors" in trans.meta_data:
66 self._show_transaction_failed_dialog(trans, enum)
67
68
69=== modified file 'softwarecenter/ui/gtk3/app.py'
70--- softwarecenter/ui/gtk3/app.py 2012-03-15 21:19:02 +0000
71+++ softwarecenter/ui/gtk3/app.py 2012-03-16 17:27:19 +0000
72@@ -476,11 +476,18 @@
73 self._gsettings.connect("changed", self._setup_proxy)
74
75 def _setup_proxy(self, setting=None, key=None):
76- proxy = get_http_proxy_string_from_gsettings()
77- if proxy:
78- os.environ["http_proxy"] = proxy
79- elif "http_proxy" in os.environ:
80- del os.environ["http_proxy"]
81+ try:
82+ proxy = get_http_proxy_string_from_gsettings()
83+ print "***", proxy
84+ if proxy:
85+ os.environ["http_proxy"] = proxy
86+ else:
87+ del os.environ["http_proxy"]
88+ except Exception as e:
89+ # if no gnome settings are installed, do not mess with
90+ # http_proxy
91+ LOG.warn("could not get proxy settings '%s'" % e)
92+ pass
93
94 # callbacks
95 def on_realize(self, widget):
96
97=== modified file 'softwarecenter/utils.py'
98--- softwarecenter/utils.py 2012-03-15 10:43:13 +0000
99+++ softwarecenter/utils.py 2012-03-16 17:27:19 +0000
100@@ -244,28 +244,33 @@
101 def get_http_proxy_string_from_gsettings():
102 """Helper that gets the http proxy from gsettings
103
104- Returns: string with http://auth:pw@proxy:port/ or None
105+ May raise a exception if there is no schema for the proxy
106+ (e.g. on non-gnome systems)
107+
108+ Returns: string with http://auth:pw@proxy:port/, None
109 """
110- try:
111- # check if this is actually available and usable. if not
112- # well ... it segfaults (thanks pygi)
113- key = "org.gnome.system.proxy.http"
114- if not key in Gio.Settings.list_schemas():
115- return None
116- settings = Gio.Settings.new(key)
117- if settings.get_boolean("enabled"):
118- authentication = ""
119- if settings.get_boolean("use-authentication"):
120- user = settings.get_string("authentication-user")
121- password = settings.get_string("authentication-password")
122- authentication = "%s:%s@" % (user, password)
123- host = settings.get_string("host")
124- port = settings.get_int("port")
125- http_proxy = "http://%s%s:%s/" % (authentication, host, port)
126- if host:
127- return http_proxy
128- except Exception:
129- logging.exception("failed to get proxy from gconf")
130+ # check if this is actually available and usable. if not
131+ # well ... it segfaults (thanks pygi)
132+ key = "org.gnome.system.proxy.http"
133+ if not key in Gio.Settings.list_schemas():
134+ raise ValueError, "no key '%s'" % key
135+ settings = Gio.Settings.new(key)
136+ if settings.get_string("host"):
137+ authentication = ""
138+ if settings.get_boolean("use-authentication"):
139+ user = settings.get_string("authentication-user")
140+ password = settings.get_string("authentication-password")
141+ authentication = "%s:%s@" % (user, password)
142+ host = settings.get_string("host")
143+ port = settings.get_int("port")
144+ # strip leading http (if there is one)
145+ if host.startswith("http://"):
146+ host = host[len("http://"):]
147+ http_proxy = "http://%s%s:%s/" % (authentication, host, port)
148+ if host:
149+ return http_proxy
150+ # no proxy
151+ return None
152
153
154 def encode_for_xml(unicode_data, encoding="ascii"):
155
156=== modified file 'utils/update-software-center-agent'
157--- utils/update-software-center-agent 2011-06-29 11:55:00 +0000
158+++ utils/update-software-center-agent 2012-03-16 17:27:19 +0000
159@@ -75,7 +75,11 @@
160 # setup path
161 pathname = XAPIAN_BASE_PATH_SOFTWARE_CENTER_AGENT+".tmp"
162 if not os.path.exists(pathname):
163- os.makedirs(pathname)
164+ try:
165+ os.makedirs(pathname)
166+ except OSError as e:
167+ logging.warn("Could not create agent dir '%s' (%s)'" % (
168+ pathname, e))
169
170 # check that we can write
171 if not os.access(pathname, os.W_OK):

Subscribers

People subscribed via source and target branches