Mercurial > getan
changeset 37:68cc10d082ab
Fix for #1569
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 15 Dec 2010 10:31:33 +0100 (2010-12-15) |
parents | e6f81aa329b1 |
children | aa6c4aca2f8d |
files | ChangeLog getan/states.py getan/utils.py |
diffstat | 3 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Oct 02 22:22:35 2010 +0200 +++ b/ChangeLog Wed Dec 15 10:31:33 2010 +0100 @@ -1,3 +1,9 @@ +2010-12-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Fix for #1569 + + * getan/states.py, getan/utils.py: used a safe int conversion. + 2010-10-02 Ingo Weinzierl <ingo.weinzierl@intevation.de> * getan/config.py: Setup the language.
--- a/getan/states.py Sat Oct 02 22:22:35 2010 +0200 +++ b/getan/states.py Wed Dec 15 10:31:33 2010 +0100 @@ -13,7 +13,7 @@ from datetime import datetime, timedelta from getan.resources import gettext as _ -from getan.utils import human_time +from getan.utils import human_time, safe_int logger = logging.getLogger() @@ -262,7 +262,7 @@ class AddTimeState(BaseTimeState): def enter(self): - minutes = int(self.view.frame.get_footer().get_edit_text()) + minutes = safe_int(self.view.frame.get_footer().get_edit_text()) project = self.view.item_in_focus() project.start -= timedelta(minutes=minutes) self.state.sec += minutes * 60 @@ -274,7 +274,7 @@ class SubtractTimeState(BaseTimeState): def enter(self): - minutes = int(self.view.frame.get_footer().get_edit_text()) + minutes = safe_int(self.view.frame.get_footer().get_edit_text()) project = self.view.item_in_focus() project.start += timedelta(minutes=minutes) self.state.sec -= minutes * 60
--- a/getan/utils.py Sat Oct 02 22:22:35 2010 +0200 +++ b/getan/utils.py Wed Dec 15 10:31:33 2010 +0100 @@ -28,6 +28,12 @@ out = "%02d:%02d:%02d" % (seconds, m, s) return out +def safe_int(s, default=0): + try: + return int(s) + except ValueError: + return default + def short_time(seconds): if seconds is None: