From 849cb7b06e1015dea8a2e6eaa1620fb968a5c5dd Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Fri, 05 Oct 2012 15:02:35 +0000 Subject: Pass JSON via POST/PUT sugar-network commands --- diff --git a/sugar-network b/sugar-network index e2f2856..831939b 100755 --- a/sugar-network +++ b/sugar-network @@ -70,6 +70,13 @@ class Application(application.Application): self._call('GET', None) def _call(self, method, content=None): + if content: + try: + content = json.loads(content) + except Exception, error: + printf.info('Cannot parse JSON from stdin: %s', error) + return + request = Request(method=method) request.content = content response = ad.Response() diff --git a/sugar_network/local/mounts.py b/sugar_network/local/mounts.py index 0c36238..cfe9a1e 100644 --- a/sugar_network/local/mounts.py +++ b/sugar_network/local/mounts.py @@ -206,11 +206,12 @@ class _ProxyCommands(object): reply.remove(prop) request['reply'] = reply elif command in (('POST', None), ('PUT', None)): - for prop in _LOCAL_PROPS.keys(): - if prop in request.content: - patch[prop] = request.content.pop(prop) - if not request.content: + if request.content is None: result = guid + else: + for prop in _LOCAL_PROPS.keys(): + if prop in request.content: + patch[prop] = request.content.pop(prop) if result is None: result = super_call(request, response) -- cgit v0.9.1