[gnome-clocks] Silently handle ENOENT
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Silently handle ENOENT
- Date: Thu, 16 Aug 2012 23:29:11 +0000 (UTC)
commit f2253faa216bdb131a8c430465beeee33248726c
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Aug 17 01:25:43 2012 +0200
Silently handle ENOENT
If the saved clocks file is not there at all that's ok, no need to
complain. Fixes bug #681859.
gnomeclocks/storage.py | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/gnomeclocks/storage.py b/gnomeclocks/storage.py
index 197c1f1..d7907ec 100644
--- a/gnomeclocks/storage.py
+++ b/gnomeclocks/storage.py
@@ -17,6 +17,7 @@
# Author: Seif Lotfy <seif lotfy collabora co uk>
import os
+import errno
import pickle
from xdg import BaseDirectory
from gi.repository import GWeather
@@ -54,22 +55,28 @@ class WorldClockStorage():
f.close()
def load_clocks(self):
+ clocks = []
try:
- f = open(DATA_PATH, "rb")
- self.locations_dump = locations = pickle.load (f)
- f.close ()
- locations = locations.split("|")
- clocks = []
- for location in locations:
- loc = location.split("---")
- if self.searchEntry.set_city(loc[0], loc[1]):
- loc = self.searchEntry.get_location ()
- loc = Location(self.searchEntry.get_location ())
- clocks.append(loc)
- return clocks
+ f = open(DATA_PATH, "rb")
+ self.locations_dump = locations = pickle.load (f)
+ f.close ()
+ locations = locations.split("|")
+ for location in locations:
+ loc = location.split("---")
+ if self.searchEntry.set_city(loc[0], loc[1]):
+ loc = self.searchEntry.get_location ()
+ loc = Location(self.searchEntry.get_location ())
+ clocks.append(loc)
+ except IOError as e:
+ if e.errno == errno.ENOENT:
+ # File does not exist yet, that's ok
+ pass
+ else:
+ print "--", e
except Exception, e:
- print "--", e
- return []
+ print "--", e
+
+ return clocks
def delete_all_clocks(self):
f = open(DATA_PATH, "w")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]