style fixes

This commit is contained in:
Tomeu Vizoso 2009-08-01 19:24:21 +02:00
parent acdc647f58
commit 43167172b9

View File

@ -209,8 +209,7 @@ class ActivityCreationHandler(gobject.GObject):
if self._service_name in ['org.laptop.JournalActivity', if self._service_name in ['org.laptop.JournalActivity',
'org.laptop.Terminal', 'org.laptop.Terminal',
'org.laptop.Log', 'org.laptop.Log',
'org.laptop.Analyze' 'org.laptop.Analyze']:
]:
self._use_rainbow = False self._use_rainbow = False
bus = dbus.SessionBus() bus = dbus.SessionBus()
@ -218,11 +217,11 @@ class ActivityCreationHandler(gobject.GObject):
bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
self._shell = dbus.Interface(bus_object, _SHELL_IFACE) self._shell = dbus.Interface(bus_object, _SHELL_IFACE)
if handle.activity_id is not None and \ if handle.activity_id is not None and handle.object_id is None:
handle.object_id is None:
datastore = dbus.Interface( datastore = dbus.Interface(
bus.get_object(_DS_SERVICE, _DS_PATH), _DS_INTERFACE) bus.get_object(_DS_SERVICE, _DS_PATH), _DS_INTERFACE)
datastore.find({ 'activity_id': self._handle.activity_id }, [], datastore.find({'activity_id': self._handle.activity_id},
[],
reply_handler=self._find_object_reply_handler, reply_handler=self._find_object_reply_handler,
error_handler=self._find_object_error_handler, error_handler=self._find_object_error_handler,
byte_arrays=True) byte_arrays=True)
@ -252,9 +251,9 @@ class ActivityCreationHandler(gobject.GObject):
self._handle.object_id, self._handle.object_id,
self._handle.uri) self._handle.uri)
envdir = None environment_dir = None
if self._use_rainbow: if self._use_rainbow:
envdir = tempfile.mkdtemp() environment_dir = tempfile.mkdtemp()
command = ['/usr/bin/sudo', '-E', '--', command = ['/usr/bin/sudo', '-E', '--',
'/usr/bin/rainbow-run', '/usr/bin/rainbow-run',
'-v', '-v', '-v', '-v',
@ -265,15 +264,33 @@ class ActivityCreationHandler(gobject.GObject):
'-c', self._bundle.get_path(), '-c', self._bundle.get_path(),
'-u', pwd.getpwuid(os.getuid()).pw_name, '-u', pwd.getpwuid(os.getuid()).pw_name,
'-i', environ['SUGAR_BUNDLE_ID'], '-i', environ['SUGAR_BUNDLE_ID'],
'-e', envdir, '-e', environment_dir,
'--' '--'
] + command ] + command
for k, v in environ.items():
open(os.path.join(envdir, str(k)), 'w').write(str(v)) for key, value in environ.items():
file_path = os.path.join(environment_dir, str(key))
open(file_path, 'w').write(str(value))
log_file.write(' '.join(command) + '\n\n') log_file.write(' '.join(command) + '\n\n')
def handler(pid, condition, user_data): dev_null = file('/dev/null', 'r')
if envdir: subprocess.call(['/bin/rm', '-rf', envdir]) child = subprocess.Popen([str(s) for s in command],
env=environ,
cwd=str(self._bundle.get_path()),
close_fds=True,
stdin=dev_null.fileno(),
stdout=log_file.fileno(),
stderr=log_file.fileno())
gobject.child_watch_add(child.pid,
self.__child_watch_cb,
(environment_dir, log_file))
def __child_watch_cb(self, pid, condition, user_data):
environment_dir, log_file = user_data
if environment_dir is not None:
subprocess.call(['/bin/rm', '-rf', environment_dir])
try: try:
log_file.write('Activity died: pid %s condition %s data %s\n' % log_file.write('Activity died: pid %s condition %s data %s\n' %
(pid, condition, user_data)) (pid, condition, user_data))
@ -287,13 +304,6 @@ class ActivityCreationHandler(gobject.GObject):
# SIGCHLD = SIG_IGN, no zombies # SIGCHLD = SIG_IGN, no zombies
pass pass
devnull = file("/dev/null", "r")
child = subprocess.Popen([str(s) for s in command], env=environ,
cwd=str(self._bundle.get_path()), close_fds=True,
stdin=devnull.fileno(), stdout=log_file.fileno(),
stderr=log_file.fileno())
gobject.child_watch_add(child.pid, handler, self._handle.activity_id)
def _no_reply_handler(self, *args): def _no_reply_handler(self, *args):
pass pass