From b44a2916ba410366078fd2f8dc5ddb10b3c4e65a Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 09 Oct 2007 16:58:39 +0000 Subject: Rework sugar.logger and make activities just redirect their output to a log. --- (limited to 'sugar/activity/activityfactory.py') diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py index addaf95..d3f279d 100644 --- a/sugar/activity/activityfactory.py +++ b/sugar/activity/activityfactory.py @@ -28,6 +28,7 @@ from sugar.presence import presenceservice from sugar.activity.activityhandle import ActivityHandle from sugar.activity import registry from sugar.datastore import datastore +from sugar import logger from sugar import util import os @@ -101,6 +102,11 @@ def get_command(activity, activity_id=None, object_id=None, uri=None): return command +def open_log_file(activity, activity_id): + name = '%s-%s.log' % (activity.bundle_id, activity_id[:5]) + path = os.path.join(logger.get_logs_dir(), name) + return open(path, 'w') + class ActivityCreationHandler(gobject.GObject): """Sugar-side activity creation interface @@ -176,12 +182,13 @@ class ActivityCreationHandler(gobject.GObject): activity = activity_registry.get_activity(self._service_name) if activity: env = get_environment(activity) - command = get_command(activity, - self._handle.activity_id, + log_file = open_log_file(activity, self._handle.activity_id) + command = get_command(activity, self._handle.activity_id, self._handle.object_id, self._handle.uri) process = subprocess.Popen(command, env=env, shell=True, - cwd=activity.path) + cwd=activity.path, stdout=log_file, + stderr=log_file) else: system_bus = dbus.SystemBus() factory = system_bus.get_object(_RAINBOW_SERVICE_NAME, -- cgit v0.9.1