def perform_sync(self, server_dir, client_dir, HOST='127.0.0.1', PORT=get_random_port(), recursive=False, config=None): config = config or {} config['host'] = HOST config['port'] = PORT config['require_auth'] = config.get('require_auth', False) #config['server_path'] = server_dir #config['client_path'] = client_dir config['clients'] = config.get('clients', {}) config['clients']['testing'] = {} #config['clients']['testing']['server_path'] = client_dir # NOTE switch client/server directory #config['clients']['testing']['client_path'] = server_dir # NOTE switch client/server directory config['clients']['testing']['server_path'] = server_dir config['clients']['testing']['client_path'] = client_dir config['clients']['testing']['recursive'] = recursive config['clients']['testing'][ 'sync_type'] = sksync.SKSYNC_PROTOCOL_TYPE_BIDIRECTIONAL_USE_TIME config = sksync.set_default_config(config) # Start sync server in thread server = sksync.MyThreadedTCPServer((HOST, PORT), sksync.MyTCPHandler) try: host, port = server.server_address server.sksync_config = config # Start a thread with the server, in turn that thread will then start additional threads # One additional thread for each client request/connection server_thread = threading.Thread(target=server.serve_forever) # Exit the server thread when the main thread terminates server_thread.daemon = True server_thread.start() #print "Server loop running in thread:", server_thread.name # do sync sksync.run_client(config, config_name='testing') finally: server.shutdown()
def local_func_run_client(): # do sync sksync.run_client(config, config_name='testing')