Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgnacio Rodriguez <ignacio@sugarlabs.org>2013-12-09 23:59:46 (GMT)
committer Ignacio Rodriguez <ignacio@sugarlabs.org>2013-12-09 23:59:46 (GMT)
commitc75602cb6b3cd4928afc044b0158235d5c1d50ec (patch)
tree61d68844c7c51cc8b807abe85d7e4275eb3bbb3c
parentd379b7d7343c6599fb0eeaed3cef9c1a93067504 (diff)
Don't crash activity, if have a error reading data
Signed-off-by: Ignacio Rodriguez <ignacio@sugarlabs.org>
-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)