Skip to content

Commit

Permalink
Fix crash handling once more.
Browse files Browse the repository at this point in the history
  • Loading branch information
BonsaiDen committed Mar 20, 2010
1 parent 1f7b25e commit ce70b0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions atarashii/usr/bin/atarashii
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ else:
print "Importing Atarashii failed"
break

elif error == os.EX_OK:
elif error in (os.EX_OK, 1): # 1 = Due to a sigkill etc.
print "Atarashii has been closed"
break

else:
atarashii.crash()
atarashii.crash(error)
if restart_count > restart_max:
break

Expand Down
3 changes: 2 additions & 1 deletion atarashii/usr/share/pyshared/atarashii/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ def show_favorite_error(self, name, mode):

def show_crash_report(self):
dialog.MessageDialog(self, MESSAGE_WARNING,
"Atarashii has crashed and automatically restarted itself.",
("Atarashii has crashed and automatically restarted itself.\n"
"<b>Error:</b> %s") % self.main.settings['crash_reason'],
lang.error_title)


Expand Down
14 changes: 9 additions & 5 deletions atarashii/usr/share/pyshared/atarashii/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def save(self):
if self.values.has_key("crashed"):
del self.values['crashed']

if self.values.has_key("time_before_crash"):
del self.values['time_before_crash']
if self.values.has_key("crash_reason"):
del self.values['crash_reason']

# Test
settings_file = open(os.path.join(self.dir, 'atarashii.conf'), "w")
Expand All @@ -110,8 +110,8 @@ def save(self):
else:
vtype = "str"

settings_file.write("%s %s %s\n" % (urllib.quote(name), vtype,
value))
settings_file.write("%s %s %s\n"
% (urllib.quote(name), vtype, value))

settings_file.close()

Expand Down Expand Up @@ -207,6 +207,9 @@ def check_autostart(self):
def check_crash(self):
self['crashed'] = os.path.exists(CRASH_FILE)
if self['crashed']:
cfp = open(CRASH_FILE, "rb")
self['crash_reason'] = cfp.read()
cfp.close()
print "ERROR: Atarashii crashed!"


Expand All @@ -227,10 +230,11 @@ def check_cache(self):

# Create Crashfile -------------------------------------------------------------
# ------------------------------------------------------------------------------
def crash_file(mode):
def crash_file(mode, data = None):
try:
if mode:
cfp = open(CRASH_FILE, "wb")
cfp.write(str(data))
cfp.close()

elif os.path.exists(CRASH_FILE):
Expand Down

0 comments on commit ce70b0b

Please sign in to comment.