diff options
author | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-09 23:59:46 (GMT) |
---|---|---|
committer | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-09 23:59:46 (GMT) |
commit | c75602cb6b3cd4928afc044b0158235d5c1d50ec (patch) | |
tree | 61d68844c7c51cc8b807abe85d7e4275eb3bbb3c | |
parent | d379b7d7343c6599fb0eeaed3cef9c1a93067504 (diff) |
Don't crash activity, if have a error reading data
Signed-off-by: Ignacio Rodriguez <ignacio@sugarlabs.org>
-rw-r--r-- | pippy_app.py | 17 |
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) |