From ad80a2fe918b5411f5ab9028eb00506b54423652 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 6 Dec 2016 16:48:53 +0000 Subject: [PATCH] fix #58; ValueError raised when reading 'cm_servers.json' --- steam/client/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/steam/client/__init__.py b/steam/client/__init__.py index bc49d05..679b10e 100644 --- a/steam/client/__init__.py +++ b/steam/client/__init__.py @@ -101,16 +101,18 @@ class SteamClient(CMClient, BuiltinBase): if not os.path.isfile(filepath): return self._LOG.debug("Reading CM servers from %s" % repr(filepath)) + try: with open(filepath, 'r') as f: data = json.load(f) + except ValueError: + self._LOG.error("Failed parsing %s", repr(filepath)) except IOError as e: - self._LOG.error("load %s: %s" % (repr(filepath), str(e))) - return - - self.cm_servers.clear() - self.cm_servers.merge_list(data['servers']) - self._cm_servers_timestamp = int(data['timestamp']) + self._LOG.error("Failed reading %s (%s)", repr(filepath), str(e)) + else: + self.cm_servers.clear() + self.cm_servers.merge_list(data['servers']) + self._cm_servers_timestamp = int(data['timestamp']) def _handle_cm_list(self, msg): if self._cm_servers_timestamp is None: