Merge lp:~dobey/ubuntuone-client/subprocess-env into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: Joshua Blount
Approved revision: 271
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/subprocess-env
Merge into: lp:ubuntuone-client
Diff against target: 95 lines
2 files modified
bin/ubuntuone-client-applet (+21/-7)
ubuntuone/oauthdesktop/auth.py (+3/-1)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/subprocess-env
Reviewer Review Type Date Requested Status
Joshua Blount (community) Approve
Vincenzo Di Somma (community) Approve
Review via email: mp+13802@code.launchpad.net

Commit message

Pass os.environ to all the subprocesses and throw them in separate threads

To post a comment you must log in.
Revision history for this message
Vincenzo Di Somma (vds) :
review: Approve
Revision history for this message
Joshua Blount (jblount) wrote :

Two thumbs, way up!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-client-applet'
2--- bin/ubuntuone-client-applet 2009-10-22 14:21:27 +0000
3+++ bin/ubuntuone-client-applet 2009-10-22 19:20:40 +0000
4@@ -41,7 +41,7 @@
5 from dbus.mainloop.glib import DBusGMainLoop
6 from ubuntuone.oauthdesktop.main import Login
7 from xdg.BaseDirectory import xdg_config_home
8-from threading import Lock
9+from threading import Lock, Thread
10 from urllib import quote
11
12 from ubuntuone.oauthdesktop.logger import setupLogging
13@@ -393,7 +393,7 @@
14
15
16
17-def do_config_open():
18+def do_config_open_real():
19 """Opens the preferences dialog."""
20 paths = os.environ["PATH"].split(":")
21 dirpath = os.path.join(os.getcwd(), "bin")
22@@ -401,18 +401,28 @@
23 paths.insert(0, dirpath)
24 os.environ["PATH"] = ":".join(paths)
25 try:
26- ret = subprocess.call(["ubuntuone-client-preferences"])
27+ ret = subprocess.call(["ubuntuone-client-preferences"],
28+ env=os.environ)
29 except OSError:
30 ret = -1
31 if ret != 0:
32 logger.error(_("Failed to open Ubuntu One preferences"))
33
34-def do_xdg_open(path_or_url):
35+def do_config_open():
36+ """Do the preferences opening in a thread."""
37+ Thread(target=do_config_open_real, name="preferences").start()
38+
39+def do_xdg_open_real(path_or_url):
40 """Utility method to run xdg-open with path_or_url."""
41- ret = subprocess.call(["xdg-open", path_or_url])
42+ ret = subprocess.call(["xdg-open", path_or_url], env=os.environ)
43 if ret != 0:
44 logger.error(_("Failed to run 'xdg-open %s'") % path_or_url)
45
46+def do_xdg_open(path_or_url):
47+ """Do the xdg-open in a thread."""
48+ Thread(target=do_xdg_open_real, name="xdg", args=(path_or_url,)).start()
49+
50+
51 class AppletIcon(gtk.StatusIcon):
52 """
53 Custom StatusIcon derived from gtk.StatusIcon which supports
54@@ -955,13 +965,17 @@
55 # Popup the status menu
56 self.emit("popup-menu", 0, gtk.get_current_event_time())
57
58- def __report_problem(self, data=None):
59+ def __report_problem_real(self):
60 """Runs apport to report a problem against our code."""
61 args = ["ubuntu-bug", "ubuntuone-client"]
62- ret = subprocess.call(args)
63+ ret = subprocess.call(args, env=os.environ)
64 if ret != 0:
65 logger.error(_("Failed to run 'ubuntu-bug'"))
66
67+ def __report_problem(self, data=None):
68+ """Pops another thread to run apport in."""
69+ Thread(target=self.__report_problem_real, name="apport").start()
70+
71 def __open_website(self, data=None, url=None):
72 """Opens the one.ubuntu.com web site."""
73 if url:
74
75=== modified file 'ubuntuone/oauthdesktop/auth.py'
76--- ubuntuone/oauthdesktop/auth.py 2009-10-21 20:51:47 +0000
77+++ ubuntuone/oauthdesktop/auth.py 2009-10-22 19:20:40 +0000
78@@ -38,6 +38,7 @@
79 ubuntuone_client_version = "Unknown"
80 from ubuntuone.oauthdesktop.key_acls import set_all_key_acls
81
82+from threading import Thread
83 from twisted.internet import reactor
84 from twisted.web import server, resource
85
86@@ -356,7 +357,8 @@
87 nodename = os.uname()[1]
88 if nodename:
89 oauth_request.set_parameter("description", nodename)
90- self.open_in_browser(oauth_request.to_url())
91+ Thread(target=self.open_in_browser, name="authorization",
92+ args=(oauth_request.to_url(),)).start()
93
94 def get_temporary_httpd(self, nonce, retrieve_function, store):
95 "A separate class so it can be mocked in testing"

Subscribers

People subscribed via source and target branches