diff options
Diffstat (limited to 'sugar_network_webui/client.py')
-rw-r--r-- | sugar_network_webui/client.py | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/sugar_network_webui/client.py b/sugar_network_webui/client.py index 88992dd..edb1da2 100644 --- a/sugar_network_webui/client.py +++ b/sugar_network_webui/client.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import json import logging +from urllib import urlencode from sugar_network.toolkit import coroutine @@ -37,8 +37,11 @@ class Client(object): _pull = None @classmethod - def call(cls, *args, **kwargs): - return _call(*args, **kwargs) + def call(cls, method, path, cmd=None, content=None, + content_type='application/json', + **kwargs): + return _call(method=method, path=path, cmd=cmd, content=content, + content_type=content_type, **kwargs) @classmethod def connect(cls, callback, **condition): @@ -54,7 +57,6 @@ class Client(object): @classmethod def _pull_events(cls): for event in Client.call('GET', [], 'subscribe'): - event = json.loads(event[6:]) for callback, condition in cls._subscriptions.items(): for key, value in condition.items(): if event.get(key) != value: @@ -72,29 +74,8 @@ class Client(object): def inline(self): return self.call('GET', [], 'inline') or Client.anonymous - def launch(self, context, command='activity', object_id=None, uri=None, - args=None): - """Launch context implementation. - - Function will call fork at the beginning. In forked process, - it will try to choose proper implementation to execute and launch it. - - Execution log will be stored in `~/.sugar/PROFILE/logs` directory. - - :param context: - context GUID to look for implementations - :param command: - command that selected implementation should support - :param object_id: - optional id to restore Journal object - :param uri: - optional uri to open; if implementation supports it - :param args: - optional list of arguments to pass to launching implementation - - """ - return self.call('GET', ['context', context], 'launch', - object_id=object_id, uri=uri, args=args) + def launch(self, context, **kwargs): + return self.call('GET', ['context', context], 'launch', spawn=True, **kwargs) def __getattr__(self, name): """Class-like object to access to a resource or call a method. |