command: use mapfiles (JSON) instead of YAML for the command server
authorW. Trevor King <wking@tremily.us>
Fri, 26 Oct 2012 17:09:21 +0000 (13:09 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 26 Oct 2012 17:09:53 +0000 (13:09 -0400)
libbe/command/base.py
libbe/command/serve_commands.py

index 61404c1d42e2bd27331a05611581c181e5047cb7..36769f11604522718c961f6945b29c9df04b6dcb 100644 (file)
@@ -24,10 +24,10 @@ import os.path
 import StringIO
 import sys
 import urlparse
-import yaml
 
 import libbe
 import libbe.storage
+import libbe.storage.util.mapfile
 import libbe.ui.util.user
 import libbe.util.encoding
 import libbe.util.http
@@ -348,10 +348,10 @@ class Command (object):
         raise NotImplementedError
 
     def _run_remote(self, **kwargs):
-        data = yaml.safe_dump({
+        data = libbe.storage.util.mapfile.generate({
                 'command': self.name,
                 'parameters': kwargs,
-                })
+                }, context=0)
         url = urlparse.urljoin(self.server, 'run')
         page,final_url,info = libbe.util.http.get_post_url(
             url=url, get=False, data=data, agent=self.user_agent)
index 4628bfb877565f5244d283ed48459e073bedb920..442beea4395649ddfa30ba59d02ee8ef914223b5 100644 (file)
@@ -30,11 +30,10 @@ import re
 import urllib
 import wsgiref.simple_server
 
-import yaml
-
 import libbe
 import libbe.command
 import libbe.command.base
+import libbe.storage.util.mapfile
 import libbe.util.wsgi
 import libbe.version
 
@@ -113,7 +112,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
 
     # handler utility functions
     def _parse_post(self, post):
-        return yaml.safe_load(post)
+        return libbe.storage.util.mapfile.parse(post)
 
     def check_login(self, environ):
         user = environ.get('be-auth.user', None)
@@ -208,10 +207,10 @@ if libbe.TESTING:
         def test_run_list(self):
             list = libbe.command.list.List()
             params = list._parse_options_args()
-            data = yaml.safe_dump({
+            data = libbe.storage.util.mapfile.generate({
                     'command': 'list',
                     'parameters': params,
-                    })
+                    }, context=0)
             self.getURL(self.app, '/run', method='POST', data=data)
             self.failUnless(self.status.startswith('200 '), self.status)
             self.failUnless(