Exemplo n.º 1
0
def test():
    parser = argparse.ArgumentParser()
    parser.add_argument('--host', type=str, nargs='?', default='localhost')
    parser.add_argument('--port', type=int, nargs='?', default=8000)
    args = parser.parse_args()
    server = ServerProxy('http://%s:%d' % (args.host, args.port))

    print 'reset'
    server.reset()
    print 'coutner:', server.counter()
    print 'generate 5 ids'
    for i in range(5):
        print server.id()
    print 'coutner:', server.counter()

    print 'generate another 5 ids'
    for i in range(5):
        print server.id()
    print 'coutner:', server.counter()

    print 'reset'
    server.reset()
    print 'coutner:', server.counter()
    print 'generate 3 ids'
    for i in range(3):
        print server.id()
    print 'coutner:', server.counter()
Exemplo n.º 2
0
class Cmd(cmd.Cmd):
    def __init__(self, host, port, *args, **kw):
        cmd.Cmd.__init__(self, *args, **kw)
        self.prompt = '%s:%d> ' % (host, port)
        self.server = ServerProxy('http://%s:%d' % (host, port))

    def do_id(self, arg):
        result = self.server.id()
        print result

    def do_counter(self, arg):
        result = self.server.counter()
        print result

    def do_reset(self, arg):
        result = self.server.reset()
        print result

    def do_EOF(self, arg):
        return True