Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-12-10 01:21:59 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-12-10 01:21:59 (GMT)
commit00cd9fd8f530c28b423b6c319f2f9e92955725a9 (patch)
tree61d68844c7c51cc8b807abe85d7e4275eb3bbb3c
parentd379b7d7343c6599fb0eeaed3cef9c1a93067504 (diff)
Don't crash activity, if have a error reading data (Ignacio Rodriguez)
-rw-r--r--pippy_app.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/pippy_app.py b/pippy_app.py
index f655c98..6a76e0d 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -631,7 +631,22 @@ Do you want to overwrite it?')
def load_from_journal(self, file_path):
if self.metadata['mime_type'] == 'text/x-python':
- text = open(file_path).read()
+ try:
+ text = open(file_path).read()
+ except:
+ from sugar3.graphics.alert import NotifyAlert
+
+ alert = NotifyAlert(10)
+ alert.props.title = _('Error')
+ alert.props.msg = _('Error reading data.')
+
+ def remove_alert(alert, response_id):
+ self.remove_alert(alert)
+
+ alert.connect("response", remove_alert)
+ self.add_alert(alert)
+ return
+
# discard the '#!/usr/bin/python' and 'coding: utf-8' lines,
# if present
text = re.sub(r'^' + re.escape(PYTHON_PREFIX), '', text)