From 00cd9fd8f530c28b423b6c319f2f9e92955725a9 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 10 Dec 2013 01:21:59 +0000 Subject: Don't crash activity, if have a error reading data (Ignacio Rodriguez) --- 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) -- cgit v0.9.1