Esempio n. 1
0
  def test_loadState(self):
    pState = pDWState()

    qState = qDWState.defaultState()

    assert(qState.getCurrentOrgID() == pState.currentOrgID())
    assert(qState.getCurrentEmail() == pState.currentOrg()['email'])

    pSvcs = pState.currentOrg()['service_tokens'].keys()
    qSvcs = qState.getCurrentServices()

    assert(jsonify(qSvcs) == jsonify(pSvcs))

    for svc in qSvcs:
      assert(qState.getCurrentServiceToken(svc) == pState.currentServiceToken(svc))
Esempio n. 2
0
def main():
    # Grab our service token.
    dwState = DatawireState.defaultState()
    token = dwState.getCurrentServiceToken('hello')

    # Start our server running...
    url = "http://127.0.0.1:8910/"

    implementation = HelloImpl()
    server = hello.HelloServer(implementation)
    server.sendCORS(True)
    server.serveHTTP(url)

    # ...and then register it with Datawire Connect.
    endpoint = DWCEndpoint('http', '127.0.0.1', 8910, url)
    options = DWCOptions(token)

    provider = DWCProvider(options, "hello", endpoint)
    provider.register(15.0)

    logging.info("registered Python server on %s" % url)
Esempio n. 3
0
def main():
    # Grab our service token.
    dwState = DatawireState.defaultState()
    token = dwState.getCurrentServiceToken('hello')

    # Start our server running...
    url = "http://127.0.0.1:8910/"

    implementation = HelloImpl()
    server = hello.HelloServer(implementation)
    server.sendCORS(True)
    server.serveHTTP(url)

    # ...and then register it with Datawire Connect.
    endpoint = DWCEndpoint('http', '127.0.0.1', 8910, url)
    options = DWCOptions(token)

    provider = DWCProvider(options, "hello", endpoint)
    provider.register(15.0)

    logging.info("registered Python server on %s" % url)
Esempio n. 4
0
def main(text):
    # Grab our service token.
    dwState = DatawireState.defaultState()
    token = dwState.getCurrentServiceToken('hello')

    # Set up the client...
    client = hello.HelloClient("hello")

    # ...and tell it that we want to use Datawire Connect to find
    # providers of this service.
    options = DWCOptions(token)
    client.setResolver(DWCResolver(options))

    # Give the resolver a chance to get connected.
    time.sleep(5)

    # OK, make the call!
    request = hello.Request()
    request.text = text

    print "Request says %r" % request.text

    response = client.hello(request)
    response. await (1.0)

    if not response.isFinished():
        print "No response!"
    elif response.getError() is not None:
        print "Response failed with %r" % response.getError()
    else:
        print "Response says %r" % response.result

    print("")
    print("")
    print("You need to interrupt me to exit at the moment, sadly.")
    print("The resolver thread isn't marked as a daemon, so it's")
    print("still lingering around.")
Esempio n. 5
0
def main(text):
    # Grab our service token.
    dwState = DatawireState.defaultState()
    token = dwState.getCurrentServiceToken('hello')

    # Set up the client...
    client = hello.HelloClient("hello")

    # ...and tell it that we want to use Datawire Connect to find 
    # providers of this service.
    options = DWCOptions(token)
    client.setResolver(DWCResolver(options))

    # Give the resolver a chance to get connected.
    time.sleep(5);

    # OK, make the call!   
    request = hello.Request()
    request.text = text

    print "Request says %r" % request.text

    response = client.hello(request)
    response.await(1.0)

    if not response.isFinished():
        print "No response!"
    elif response.getError() is not None:
        print "Response failed with %r" % response.getError()
    else:
        print "Response says %r" % response.result

    print("")
    print("")
    print("You need to interrupt me to exit at the moment, sadly.")
    print("The resolver thread isn't marked as a daemon, so it's")
    print("still lingering around.")
Esempio n. 6
0
    qContents = qState.defaultStateContents()
    qJSON = jsonify(json.loads(qContents))

    assert(pJSON == qJSON)

  def test_loadState(self):
    pState = pDWState()

    qState = qDWState.defaultState()

    assert(qState.getCurrentOrgID() == pState.currentOrgID())
    assert(qState.getCurrentEmail() == pState.currentOrg()['email'])

    pSvcs = pState.currentOrg()['service_tokens'].keys()
    qSvcs = qState.getCurrentServices()

    assert(jsonify(qSvcs) == jsonify(pSvcs))

    for svc in qSvcs:
      assert(qState.getCurrentServiceToken(svc) == pState.currentServiceToken(svc))

if __name__ == '__main__':
    qState = qDWState.defaultState()

    print("%s" % qState.defaultStatePath()) 
    print("%s" % qState.getCurrentOrgID())
    print("%s" % qState.getCurrentEmail())

    for svc in qState.getCurrentServices():
        print("%s:::%s" % (svc, qState.getCurrentServiceToken(svc)))