From 93a6b6bc8b7f9370440e43388abe597933dc23e3 Mon Sep 17 00:00:00 2001 From: Harihar Shankar Date: Tue, 12 Aug 2014 08:29:39 -0600 Subject: [PATCH] updated the file permission error capture when reading subscribers as well --- resourcesync_push/hub/hub.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resourcesync_push/hub/hub.py b/resourcesync_push/hub/hub.py index d3ceefc..591270b 100755 --- a/resourcesync_push/hub/hub.py +++ b/resourcesync_push/hub/hub.py @@ -51,6 +51,7 @@ def read_subscriptions(self): data = cPickle.load(sub_file) except (IOError, EOFError) as err: print(err) + return None finally: if sub_file: sub_file.close() @@ -132,6 +133,8 @@ def publish_push_payload(self, future_session, response): """ subscriptions = self.read_subscriptions() + if not subscriptions: + return self.respond(code=500, msg="Error reading subscriptions.") subscribers = subscriptions.get(self.push_url, None) if not subscribers: return self.respond(code=204, msg="") @@ -172,6 +175,8 @@ def handle_resourcesync_request(self, content_type="application/xml"): msg="Topic is not registered with the hub.") subscriptions = self.read_subscriptions() + if not subscriptions: + return self.respond(code=500, msg="Error reading subscriptions.") subscribers = subscriptions.get(topic, None) if not subscribers: return self.respond(code=204)