Improve error-handling during activity log-file creation.

This commit is contained in:
Michael Stone 2007-11-09 12:11:43 -05:00
parent b3fa0c001c
commit 8bd8ec6216

View File

@ -28,6 +28,8 @@ from sugar.activity import registry
from sugar import util from sugar import util
from sugar import env from sugar import env
from errno import EEXIST
import os import os
# #3903 - this constant can be removed and assumed to be 1 when dbus-python # #3903 - this constant can be removed and assumed to be 1 when dbus-python
@ -98,6 +100,7 @@ def get_environment(activity):
environ['SUGAR_BUNDLE_ID'] = activity.bundle_id environ['SUGAR_BUNDLE_ID'] = activity.bundle_id
environ['SUGAR_ACTIVITY_ROOT'] = activity_root environ['SUGAR_ACTIVITY_ROOT'] = activity_root
environ['PATH'] = bin_path + ':' + environ['PATH'] environ['PATH'] = bin_path + ':' + environ['PATH']
#environ['RAINBOW_STRACE_LOG'] = '1'
return environ return environ
@ -127,8 +130,11 @@ def open_log_file(activity):
| os.O_SYNC | os.O_WRONLY, 0644) | os.O_SYNC | os.O_WRONLY, 0644)
f = os.fdopen(fd, 'w', 0) f = os.fdopen(fd, 'w', 0)
return (path, f) return (path, f)
except: except OSError, e:
if e.errno == EEXIST:
i += 1 i += 1
else:
raise e
class ActivityCreationHandler(gobject.GObject): class ActivityCreationHandler(gobject.GObject):
"""Sugar-side activity creation interface """Sugar-side activity creation interface