Skip to content

Commit

Permalink
add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
dankilman committed Feb 5, 2019
1 parent c82207e commit 5a89118
Show file tree
Hide file tree
Showing 22 changed files with 580 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Your contributions to this world are greatly appreciated.
- [txaio (MIT)](https://github.com/crossbario/txaio)
- [pydash (MIT)](https://github.com/dgilland/pydash)
- [requests (Apache License, Version 2.0)](https://github.com/requests/requests)
- [click (BSD)](https://github.com/pallets/click)
- [react (MIT)](https://github.com/facebook/react)
- [redux (MIT)](https://github.com/reduxjs/redux)
- [ant-design (MIT)](https://github.com/ant-design/ant-design)
Expand Down
15 changes: 10 additions & 5 deletions awe/api_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import requests


DEFAULT_HOST = '127.0.0.1'
DEFAULT_PORT = 8080
DEFAULT_WEBSOCKET_PORT = 9000


class APIClient(object):

def __init__(self, host='127.0.0.1', port=8080):
def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT):
"""
REST API client.
Expand All @@ -12,9 +17,9 @@ def __init__(self, host='127.0.0.1', port=8080):
:param host: ``awe`` server host.
:param port: ``awe`` server port.
"""
self.host = host
self.port = port
self._base_url = 'http://{}:{}/api'.format(host, port)
self.host = host or DEFAULT_HOST
self.port = port or DEFAULT_PORT
self._base_url = 'http://{}:{}/api'.format(self.host, self.port)

def get_status(self):
"""
Expand Down Expand Up @@ -49,7 +54,7 @@ def new_element(self, obj, params=None, element_id=None, root_id=None, parent_id
:param obj: The ``obj`` argument as expected by the ``new()`` method.
:param params: Params to pass on to the ``new()`` method invocation.
:param element_id: Optionally specify an ``element_id``. (one will be generated otherwise)
:param root_id: Optionally specify a different root to created the element under.
:param root_id: Optionally specify a different root to create the element under.
If not specified, and ``parent_id`` is not supplied, the main ``page`` root will be used.
:param parent_id: Optionally specify the element to call the ``new()`` method on.
:param new_root: Pass ``True`` to create the element under a new root.
Expand Down
4 changes: 3 additions & 1 deletion awe/chart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import time

import six

from .view import Element, builtin

number_types = (int, float)
Expand Down Expand Up @@ -269,7 +271,7 @@ def _get_transformer(transform):
elif isinstance(transformer, dict):
transformer_key = transformer.pop('type')
return transformer_classes[transformer_key](**transformer)
if isinstance(transformer, str):
if isinstance(transformer, six.string_types):
if transformer in transformers:
return transformers[transformer]
maybe_dict_transformer = DictLevelsTransformer.from_str(transformer)
Expand Down

0 comments on commit 5a89118

Please sign in to comment.