Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-10-05 15:02:35 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-10-05 15:02:35 (GMT)
commit849cb7b06e1015dea8a2e6eaa1620fb968a5c5dd (patch)
tree27f16ba68869650b9cda6e0f9ec25a7ae70b5163
parent1c7a9ebd496807e3528aacac952602763d51f8e2 (diff)
Pass JSON via POST/PUT sugar-network commands
-rwxr-xr-xsugar-network7
-rw-r--r--sugar_network/local/mounts.py9
2 files changed, 12 insertions, 4 deletions
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)