Esempio n. 1
0
File: soapi.py Progetto: nco/swamp
def pingTest(confFilename):
    """
    ping a server specified by a configuration file.
    """
    from twisted.web.soap import Proxy
    from twisted.internet import reactor
    import time

    c = Config(confFilename)
    c.read()
    url = "http://%s:%d/%s" % (c.slaveHostname,
                               c.slavePort,
                               c.slaveSoapPath)
    print "using url",url
    proxy = Proxy(url)
    t = time.time()
    call = proxy.callRemote('ping')

    def succ(cook):
        e = time.time()
        print "success ",cook
        a = cook.split()
        firsthalf = float(a[1]) - t
        total = e-t
        print "total time: %f firsthalf: %f" %(total, firsthalf)
        reactor.stop()
    def fail(reason):
        print "fail",reason
        reactor.stop()
    call.addCallbacks(succ, fail)
    reactor.run()
from twisted.web.soap import Proxy

from twisted.internet import reactor


def printResult(value):
    print repr(value)
    reactor.stop()


def printError(error):
    print 'Error', error
    reactor.stop()


proxy = Proxy('http://localhost:8443/SOAP')
proxy.callRemote('listdir', 'User').addCallbacks(printResult, printError)
reactor.run()
Esempio n. 3
0
    print "Usage: %s <URL> <OPTIONS> \n" % (sys.argv[0])
    print "Options:"
    print "   -a <add_options> \t add photos"
    print "      -f <file_json> \t specified the JSON file"
    print "      -d <path> \t specified the images directory"
    print "\n"
    print "   -q <file> \t send query file"
    print "   -g <file> \t generate the image index"
    print "\n"
    exit(-1)

url = sys.argv[1]
option = sys.argv[2]
path = None

proxy = Proxy(url)

if (option == "-a"):
    suboption = sys.argv[3]
    path = sys.argv[4]

    if (suboption == "-f"):
        f = open(path, 'r')
        json = f.read()
        f.close()

        proxy.callRemote('add_photo', json).addCallbacks(callback, errback)
        reactor.run()

    elif (suboption == "-d"):
    print "Usage: %s <URL> <OPTIONS> \n" %(sys.argv[0])
    print "Options:"
    print "   -a <add_options> \t add photos"
    print "      -f <file_json> \t specified the JSON file"
    print "      -d <path> \t specified the images directory"
    print "\n"
    print "   -q <file> \t send query file"
    print "   -g <file> \t generate the image index"
    print "\n"
    exit(-1) 

url = sys.argv[1]
option = sys.argv[2]
path = None

proxy = Proxy(url)

if (option == "-a"):
    suboption = sys.argv[3]
    path = sys.argv[4]
    
    if (suboption == "-f"):
        f = open(path, 'r')
        json = f.read()
        f.close()
        
        proxy.callRemote('add_photo', json).addCallbacks(callback, errback)
        reactor.run()
        
    elif (suboption == "-d"):
    
from twisted.web.soap import Proxy

from twisted.internet import reactor

def printResult(value):
    print repr(value)
    reactor.stop()

def printError(error):
    print 'Error', error
    reactor.stop()

proxy = Proxy('http://localhost:8443/SOAP')
proxy.callRemote('listdir', 'User').addCallbacks(printResult, printError)
reactor.run()
Esempio n. 6
0
from twisted.web.soap import Proxy
from twisted.internet import reactor


def printValue(value):
    print repr(value)
    reactor.stop()


def printError(error):
    print 'error', error
    reactor.stop()


proxy = Proxy('http://127.0.0.1:7080/SOAP')
proxy.callRemote('myself').addCallbacks(printValue, printError)
reactor.run()