Example #1
0
 def __init__(self, reactor, cap_table, read_only_dbs, writable_db, http_endpoint, ws_endpoint, root_cap, title, flowgraph_for_debug):
     # Constants
     self.__http_endpoint_string = http_endpoint
     self.__http_endpoint = endpoints.serverFromString(reactor, http_endpoint)
     self.__ws_endpoint = endpoints.serverFromString(reactor, ws_endpoint)
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(ws_endpoint_string=ws_endpoint)
     
     def BoundSessionResource(session):
         return SessionResource(session, wcommon, reactor, title, read_only_dbs, writable_db, flowgraph_for_debug)
     
     server_root = CapAccessResource(cap_table=cap_table, resource_ctor=BoundSessionResource)
     _put_root_static(server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(OurStreamProtocol, cap_table))
     self.__site = _SiteWithHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #2
0
 def __init__(self, reactor, cap_table, http_endpoint, ws_endpoint, root_cap, title):
     # Constants
     self.__http_endpoint_string = str(http_endpoint)
     self.__http_endpoint = endpoints.serverFromString(reactor, self.__http_endpoint_string)
     self.__ws_endpoint = endpoints.serverFromString(reactor, str(ws_endpoint))
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(
         reactor=reactor,
         title=title,
         ws_endpoint_string=ws_endpoint)
     # TODO: Create poller actually for the given reactor w/o redundancy -- perhaps there should be a one-poller-per-reactor map
     subscription_context = SubscriptionContext(reactor=reactor, poller=the_poller)
     
     def resource_factory(entry_point):
         # TODO: If not an IWebEntryPoint, return a generic result
         return IWebEntryPoint(entry_point).get_entry_point_resource(wcommon=wcommon)  # pylint: disable=redundant-keyword-arg
     
     server_root = CapAccessResource(cap_table=cap_table, resource_factory=resource_factory)
     _put_root_static(wcommon, server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(WebSocketDispatcherProtocol, cap_table, subscription_context))
     self.__site = SiteWithDefaultHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #3
0
 def __init__(self, reactor, cap_table, http_endpoint, ws_endpoint, root_cap, title):
     # Constants
     self.__http_endpoint_string = str(http_endpoint)
     self.__http_endpoint = endpoints.serverFromString(reactor, self.__http_endpoint_string)
     self.__ws_endpoint = endpoints.serverFromString(reactor, str(ws_endpoint))
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(
         reactor=reactor,
         title=title,
         ws_endpoint_string=ws_endpoint)
     # TODO: Create poller actually for the given reactor w/o redundancy -- perhaps there should be a one-poller-per-reactor map
     subscription_context = SubscriptionContext(reactor=reactor, poller=the_poller)
     
     def resource_factory(entry_point):
         # TODO: If not an IWebEntryPoint, return a generic result
         return IWebEntryPoint(entry_point).get_entry_point_resource(wcommon=wcommon)  # pylint: disable=redundant-keyword-arg
     
     server_root = CapAccessResource(cap_table=cap_table, resource_factory=resource_factory)
     _put_root_static(wcommon, server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(OurStreamProtocol, cap_table, subscription_context))
     self.__site = _SiteWithHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #4
0
 def __init__(self, reactor, cap_table, read_only_dbs, writable_db, http_endpoint, ws_endpoint, root_cap, title, flowgraph_for_debug):
     # Constants
     self.__http_endpoint_string = http_endpoint
     self.__http_endpoint = endpoints.serverFromString(reactor, http_endpoint)
     self.__ws_endpoint = endpoints.serverFromString(reactor, ws_endpoint)
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(ws_endpoint_string=ws_endpoint)
     
     def BoundSessionResource(session):
         return SessionResource(session, wcommon, reactor, title, read_only_dbs, writable_db, flowgraph_for_debug)
     
     server_root = CapAccessResource(cap_table=cap_table, resource_ctor=BoundSessionResource)
     _put_root_static(server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(OurStreamProtocol, cap_table))
     self.__site = _SiteWithHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #5
0
    def __init__(self, reactor, root_object, read_only_dbs, writable_db,
                 http_endpoint, ws_endpoint, root_cap, title,
                 flowgraph_for_debug):
        # Constants
        self.__http_port = http_endpoint
        self.__ws_port = ws_endpoint

        wcommon = WebServiceCommon(ws_endpoint=ws_endpoint)

        # Roots of resource trees
        # - app_root is everything stateful/authority-bearing
        # - server_root is the HTTP '/' and static resources are placed there
        server_root = Resource()
        if root_cap is None:
            app_root = server_root
            self.__visit_path = '/'
            ws_caps = {None: root_object}
        else:
            app_root = SlashedResource()
            server_root.putChild(root_cap, app_root)
            self.__visit_path = '/' + urllib.quote(root_cap, safe='') + '/'
            ws_caps = {root_cap: root_object}

        # Note: in the root_cap = None case, it matters that the session is done second as it overwrites the definition of /.
        _put_root_static(server_root)
        _put_session(app_root, root_object, wcommon, reactor, title,
                     read_only_dbs, writable_db, flowgraph_for_debug)

        self.__ws_protocol = txws.WebSocketFactory(
            FactoryWithArgs.forProtocol(OurStreamProtocol, ws_caps))
        self.__site = server.Site(server_root)

        self.__ws_port_obj = None
        self.__http_port_obj = None
Example #6
0
 def __init__(self, reactor, root_object, read_only_dbs, writable_db, http_endpoint, ws_endpoint, root_cap, title, flowgraph_for_debug):
     # Constants
     self.__http_port = http_endpoint
     self.__ws_port = ws_endpoint
     
     wcommon = WebServiceCommon(ws_endpoint=ws_endpoint)
     
     # Roots of resource trees
     # - app_root is everything stateful/authority-bearing
     # - server_root is the HTTP '/' and static resources are placed there
     server_root = Resource()
     if root_cap is None:
         app_root = server_root
         self.__visit_path = '/'
         ws_caps = {None: root_object}
     else:
         app_root = SlashedResource()
         server_root.putChild(root_cap, app_root)
         self.__visit_path = '/' + urllib.quote(root_cap, safe='') + '/'
         ws_caps = {root_cap: root_object}
     
     # Note: in the root_cap = None case, it matters that the session is done second as it overwrites the definition of /.
     _put_root_static(server_root)
     _put_session(app_root, root_object, wcommon, reactor, title, read_only_dbs, writable_db, flowgraph_for_debug)
     
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(OurStreamProtocol, ws_caps))
     self.__site = server.Site(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #7
0
 def __init__(self, reactor, root_object, note_dirty, read_only_dbs, writable_db, http_endpoint, ws_endpoint, root_cap, title, flowgraph_for_debug):
     self.__http_port = http_endpoint
     self.__ws_port = ws_endpoint
     
     wcommon = WebServiceCommon(note_dirty=note_dirty, ws_endpoint=ws_endpoint)
     
     # Roots of resource trees
     # - appRoot is everything stateful/authority-bearing
     # - serverRoot is the HTTP '/' and static resources are placed there
     serverRoot = _make_static(static_resource_path)
     if root_cap is None:
         appRoot = serverRoot
         self.__visit_path = '/'
         ws_caps = {None: root_object}
     else:
         serverRoot = _make_static(static_resource_path)
         appRoot = SlashedResource()
         serverRoot.putChild(root_cap, appRoot)
         self.__visit_path = '/' + urllib.quote(root_cap, safe='') + '/'
         ws_caps = {root_cap: root_object}
     
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(OurStreamProtocol, ws_caps, note_dirty))
     
     # UI entry point
     appRoot.putChild('', _RadioIndexHtmlResource(wcommon=wcommon, title=title))
     
     # Exported radio control objects
     appRoot.putChild('radio', BlockResource(root_object, wcommon, not_deletable))
     
     # Frequency DB
     appRoot.putChild('dbs', shinysdr.i.db.DatabasesResource(read_only_dbs))
     appRoot.putChild('wdb', shinysdr.i.db.DatabaseResource(writable_db))
     
     # Debug graph
     appRoot.putChild('flow-graph', FlowgraphVizResource(reactor, flowgraph_for_debug))
     
     # Ephemeris
     appRoot.putChild('ephemeris', EphemerisResource())
     
     # Construct explicit resources for merge.
     test = _reify(serverRoot, 'test')
     jasmine = _reify(test, 'jasmine')
     for name in ['jasmine.css', 'jasmine.js', 'jasmine-html.js']:
         jasmine.putChild(name, static.File(os.path.join(
             deps_path, 'jasmine/lib/jasmine-core/', name)))
     
     client = _reify(serverRoot, 'client')
     client.putChild('require.js', static.File(os.path.join(deps_path, 'require.js')))
     client.putChild('text.js', static.File(os.path.join(deps_path, 'text.js')))
     
     _add_plugin_resources(client)
     
     self.__site = server.Site(serverRoot)
     self.__ws_port_obj = None
     self.__http_port_obj = None
Example #8
0
def connect_to_rig(reactor, port, baudrate=38400):
    """
    Connect to Elecraft radio over a serial port.
    
    port: Serial port device name.
    baudrate: Serial data rate; must match that set on the radio.
    """
    endpoint = SerialPortEndpoint(port, reactor, baudrate=baudrate)
    factory = FactoryWithArgs.forProtocol(_ElecraftClientProtocol, reactor)
    protocol = yield endpoint.connect(factory)
    proxy = protocol._proxy()

    defer.returnValue(
        Device(vfo_cell=proxy.iq_center_cell(), components={'rig': proxy}))
Example #9
0
def connect_to_rig(reactor, port, baudrate=38400):
    """
    Connect to Elecraft radio over a serial port.
    
    port: Serial port device name.
    baudrate: Serial data rate; must match that set on the radio.
    """
    endpoint = SerialPortEndpoint(port, reactor, baudrate=baudrate)
    factory = FactoryWithArgs.forProtocol(_ElecraftClientProtocol, reactor)
    protocol = yield endpoint.connect(factory)
    proxy = protocol._proxy()
    
    defer.returnValue(Device(
        vfo_cell=proxy.iq_center_cell(),
        components={'rig': proxy}))
Example #10
0
    def __init__(self, reactor, cap_table, read_only_dbs, writable_db,
                 http_endpoint, ws_endpoint, root_cap, title,
                 flowgraph_for_debug):
        # Constants
        self.__http_endpoint_string = http_endpoint
        self.__http_endpoint = endpoints.serverFromString(
            reactor, http_endpoint)
        self.__ws_endpoint = endpoints.serverFromString(reactor, ws_endpoint)
        self.__visit_path = _make_cap_url(root_cap)

        wcommon = WebServiceCommon(ws_endpoint_string=ws_endpoint)
        # TODO: Create poller actually for the given reactor w/o redundancy -- perhaps there should be a one-poller-per-reactor map
        subscription_context = SubscriptionContext(reactor=reactor,
                                                   poller=the_poller)

        def BoundSessionResource(session):
            return SessionResource(session, wcommon, reactor, title,
                                   read_only_dbs, writable_db,
                                   flowgraph_for_debug)

        server_root = CapAccessResource(cap_table=cap_table,
                                        resource_ctor=BoundSessionResource)
        _put_root_static(server_root)

        if UNIQUE_PUBLIC_CAP in cap_table:
            # TODO: consider factoring out "generate URL for cap"
            server_root.putChild('',
                                 Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))

        self.__ws_protocol = txws.WebSocketFactory(
            FactoryWithArgs.forProtocol(OurStreamProtocol, cap_table,
                                        subscription_context))
        self.__site = _SiteWithHeaders(server_root)

        self.__ws_port_obj = None
        self.__http_port_obj = None
Example #11
0
 def startService(self):
     self.__port_obj = yield self.__endpoint.listen(
         FactoryWithArgs.forProtocol(_DspserverProtocol, self.__top))
Example #12
0
 def startService(self):
     self.__port_obj = strports.listen(self.__endpoint, FactoryWithArgs.forProtocol(_DspserverProtocol, self.__top))