From 853d9ef0f6f42b61bab4e42b759697e1e9475b79 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 6 Mar 2012 17:49:17 +0100 Subject: [PATCH] warn if config can not be parsed, allow upload filename --- pandora_client/__init__.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 0827f40..16c8b75 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -71,7 +71,11 @@ class Client(object): if isinstance(config, basestring): self._configfile = config with open(config) as f: - self._config = json.load(f) + try: + self._config = json.load(f) + except ValueError: + print "Failed to parse config at", config + sys.exit(1) else: self._config = config @@ -441,10 +445,21 @@ class Client(object): print "you need to login" return conn, c = self._conn() - if args: - data = args + info = {} + data = [] + for arg in args: + if os.path.exists(arg): + self.scan_file(arg) + oshash = ox.oshash(arg) + info[oshash] = self.info(oshash) + args.append(oshash) + else: + args.append(arg) files = [] + if info: + post = {'info': info} + r = self.api.update(post) else: #send empty list to get updated list of requested info/files/data post = {'info': {}}