Beispiel #1
0
class ExpControlClient:
    
    
    def __init__(self, controller_host, controller_port=16633):        
    
        raw_sock = socket.create_connection((controller_host, controller_port))
        self.sock = SessionSocket(raw_sock)
        
    
    
    def execute(self, cmd):
        
        self.sock.send(cmd)
        return self.sock.recv()
Beispiel #2
0
class StateProxyClient:
    
    def __init__(self, proxy_host, port=StateProxyServer.DEFAULT_LISTEN_PORT):
        raw_sock = socket.create_connection((proxy_host, port))
        self._sock = SessionSocket(raw_sock)
        
    def hello(self):
        self._sock.send(['HELLO'])
        assert self._sock.recv() == 'Hi there!'
        
    def get(self, attr):
        self._sock.send(['GET', str(attr)])
        return self._sock.recv()
    
    def getall(self):
        self._sock.send(['GETALL'])
        return self._sock.recv()
    
    def set(self, attr, value):
        self._sock.send(['SET', str(attr), value])
        assert self._sock.recv() == 'OK'
        
    def reset(self):
        self._sock.send(['RESET']) 
        assert self._sock.recv() == 'OK'
        
    def run(self, func_name, *args):
        self._sock.send(['RUN', str(func_name)] + list(args))
        return self._sock.recv()
    
    def exit(self):
        self._sock.send(['EXIT'])