def main(): sys.stdout.write("Android Gateway Pull Test\n") if len(sys.argv) != 3: sys.stderr.write("Usage: %s <host> <port> \n" % sys.argv[0]) sys.exit(-1) deviceName = "device:test/" + uuid.uuid1().hex userName = "******" + uuid.uuid1().hex connector = AndroidConnector(sys.argv[1], int(sys.argv[2]), deviceName, userName, "") try: connector.start() connector.waitForAuthentication() # Pull request options... For LDAP pull, only the first two are important (as of now) mimetype = "ammo/edu.vu.isis.ammo.launcher.contact_pull" query = "cn=John" maxResults = 0 startFromCount = 0 liveQuery = False # Send the pull request connector.pullRequest(mimetype, query, "", maxResults, startFromCount, liveQuery) while True: while(connector.isDataAvailable()): result = connector.dequeueMessage() if(result != None): (msg, receivedTime) = result print "Message received at:", receivedTime print msg time.sleep(0.5) except KeyboardInterrupt: sys.stdout.write("Got ^C... Closing\n") reactor.callFromThread(reactor.stop) except: sys.stderr.write("Unexpected error... dying.\n") reactor.callFromThread(reactor.stop) raise
query += middleInitial + "," query += lastName + "," query += rank + "," query += call_sign + "," query += branch + "," query += phone + "," query += email + "," # Private contacts data is not stored as a blob so we don't use a projection string projection = "" maxResults = 0 startFromCount = 0 liveQuery = False connector.pullRequest(mimeType, query, projection, maxResults, startFromCount, liveQuery) while True: while(connector.isDataAvailable()): result = connector.dequeueMessage() if(result != None): (msg, receivedTime) = result print "Message received at:", receivedTime print msg time.sleep(0.5) except KeyboardInterrupt: print "Got ^C... Closing" reactor.callFromThread(reactor.stop) # re-raising the exception so we get a traceback (useful for debugging, # occasionally). Real "applications"/testdrivers shouldn't do this.
print "Usage: ", sys.argv[0], "host port" exit(-1) deviceName = "device:test/" + uuid.uuid1().hex userName = "******" + uuid.uuid1().hex connector = AndroidConnector(sys.argv[1], int(sys.argv[2]), deviceName, userName, "") try: connector.start() connector.waitForAuthentication() print "Subscribing to type text/plain" connector.push("someUri", "blah_asdf", "directed message from user " + userName) connector.pullRequest("blah", ",,1302228081,,stuff", "", 0, 0, False) while True: while(connector.isDataAvailable()): result = connector.dequeueMessage() if(result != None): (msg, receivedTime) = result print "Message received at:", receivedTime print msg time.sleep(0.5) except KeyboardInterrupt: print "Got ^C... Closing" reactor.callFromThread(reactor.stop) # re-raising the exception so we get a traceback (useful for debugging, # occasionally). Real "ammo"/testdrivers shouldn't do this.