def __init__(self): MyBase.__init__(self, debug=False) try: self.conn = sk.create_connection((HOST, PORT)) except: self._server_start() self.conn = sk.create_connection((HOST, PORT))
def __init__(self): MyBase.__init__(self, debug=True) self.sock = sk.socket(sk.AF_INET, sk.SOCK_STREAM) self.sock.setsockopt(sk.SOL_SOCKET, sk.SO_REUSEADDR, 1) self.sock.settimeout(TIMEOUT) try: self.sock.bind((HOST, PORT)) self.sock.listen(MAX_CLIENT) self._debug('server is started.') except sk.error: self._debug('server is already running.') self.Stop()
def main(server_num): print("Starting server {}".format(server_num)) base = MyBase() ip = socket.gethostbyname(socket.gethostname()) port = 1234 server = SimpleXMLRPCServer((ip, port)) server.register_instance(base) server.serve_forever()
def __init__(self): MyBase.__init__(self, debug=False) self.client = pm.SSHClient() self.client.set_missing_host_key_policy(pm.AutoAddPolicy())