Пример #1
0
 def __construct_api_files():
     if not utils.are_we_frozen():
         HubsInspector.construct_js_file(path=os.path.join(
             "libs", "WSCommunication", "Clients", "hubsApi.js"))
         HubsInspector.construct_js_file(
             path=os.path.join(os.pardir, "demo", "_static", "hubsApi.js"))
         HubsInspector.construct_python_file(path=os.path.join(
             "libs", "WSCommunication", "Clients", "hubs_api.py"))
    def test_PythonCreation_withClientFunctions(self):
        class TestHubWithClient(Hub):
            def get_data(self):
                pass

            def _define_client_functions(self):
                return dict(client1=lambda x, y: None,
                            client2=lambda x, y=1: None,
                            client3=lambda x=0, y=1: None)

        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        HubsInspector.construct_python_file()

        self.assertTrue(os.path.exists(HubsInspector.DEFAULT_PY_API_FILE_NAME))
import os
import logging.config
import json
from tornado import web, ioloop

from wshubsapi.hubs_inspector import HubsInspector
from wshubsapi.connection_handlers.tornado_handler import ConnectionHandler

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

settings = {"static_path": os.path.join(os.path.dirname(__file__), "../Clients/_static")}

app = web.Application([
    (r'/(.*)', ConnectionHandler),
], **settings)

if __name__ == '__main__':
    HubsInspector.include_hubs_in("*_hub.py")  # use glob path patterns
    HubsInspector.inspect_implemented_hubs()
    HubsInspector.construct_js_file(settings["static_path"] + os.sep + "hubsApi.js")
    HubsInspector.construct_python_file(settings["static_path"] + os.sep + "hubs_api.py")
    HubsInspector.construct_dart_file(settings["static_path"] + os.sep + "hubs_api.dart")
    log.debug("starting...")
    app.listen(8888)

    ioloop.IOLoop.instance().start()
Пример #4
0
 def __construct_api_files():
     if not utils.are_we_frozen():
         HubsInspector.construct_js_file(path=os.path.join("libs", "WSCommunication", "Clients", "hubsApi.js"))
         HubsInspector.construct_js_file(path=os.path.join(os.pardir, "demo", "_static", "hubsApi.js"))
         HubsInspector.construct_python_file(path=os.path.join("libs", "WSCommunication", "Clients", "hubs_api.py"))
Пример #5
0
from wsgiref.simple_server import make_server

from ws4py.server.wsgirefserver import WSGIServer, WebSocketWSGIRequestHandler
from ws4py.server.wsgiutils import WebSocketWSGIApplication

from wshubsapi.connection_handlers.ws4py_handler import ConnectionHandler
from wshubsapi.hubs_inspector import HubsInspector

if __name__ == '__main__':
    HubsInspector.include_hubs_in("*_hub.py")  # use glob path patterns
    HubsInspector.inspect_implemented_hubs()  # setup api
    HubsInspector.construct_python_file("../Clients/_static/hubs_api.py")  # only if you will use a python client
    HubsInspector.construct_js_file("../Clients/_static/hubsApi.js")  # only if you will use a js client

    server = make_server('127.0.0.1', 8888, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ConnectionHandler))
    server.initialize_websockets_manager()
    server.serve_forever()
    def test_PythonCreation_default_values(self):
        HubsInspector.construct_python_file()

        self.assertTrue(os.path.exists(HubsInspector.DEFAULT_PY_API_FILE_NAME))
        self.assertTrue(os.path.exists("__init__.py"), "Check if python package is created")
 def test_PythonCreation_new_path(self):
     full_path = os.path.join(self.other_folder, self.other_name)
     package_file_path = os.path.join(self.other_folder, "__init__.py")
     HubsInspector.construct_python_file(full_path)
     self.assertTrue(os.path.exists(full_path))
     self.assertTrue(os.path.exists(package_file_path), "Check if python package is created")
Пример #8
0
from wshubsapi.hubs_inspector import HubsInspector

if __name__ == '__main__':
    HubsInspector.include_hubs_in("*_hub.py")  # use glob path patterns
    HubsInspector.inspect_implemented_hubs()
    HubsInspector.construct_python_file("module_api/hubs_api.py")
import json
import logging.config

from wshubsapi.hubs_inspector import HubsInspector
from wshubsapi.connection_handlers.socket_handler import create_socket_server

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

if __name__ == '__main__':
    HubsInspector.include_hubs_in("*_hub.py")  # use glob path patterns
    # construct the necessary client files in the specified path
    HubsInspector.inspect_implemented_hubs()
    HubsInspector.construct_python_file("../Clients/_static/hubs_api.py")

    server = create_socket_server("127.0.0.1", 8890)

    server.serve_forever()


Пример #10
0
from wshubsapi.hubs_inspector import HubsInspector

if __name__ == '__main__':
    HubsInspector.include_hubs_in("*_hub.py")  # use glob path patterns
    HubsInspector.inspect_implemented_hubs()
    HubsInspector.construct_python_file("Clients/hubs_api.py")