def mapleDeployment(host, loacalMaple, loaclMapleHandler, loaclMapleDataMerger, loaclGetDestination): # create the deployment mach = SshMachine(host, user="******", keyfile="/home/zitongc2/.ssh/id_rsa") server = DeployedServer(mach) # and now you can connect to it the usual way conn = server.classic_connect() print("[INFO] Connected to ", host) conn._config['sync_request_timeout'] = None def getResult(string): print(string) remoteMaple = conn.teleport(loacalMaple) remoteMapleHandler = teleport_function(conn, loaclMapleHandler) remoteMapleHandler(remoteMaple, "/home/zitongc2/test/phase0/input", getResult) # print("[INFO] Done processing, now sendind result to desinated location") remoteMapleDataMerger = teleport_function(conn, loaclMapleDataMerger) remoteMapleDataMerger(loaclGetDestination) # when you're done - close the server and everything will disappear print("[INFO] done") server.close()
def test_globals(self): def the_answer(): return THE_ANSWER # noqa teleported = teleport_function(self.conn, the_answer) self.conn.namespace['THE_ANSWER'] = 42 self.assertEqual(teleported(), 42) the_globals = self.conn.builtins.dict({'THE_ANSWER': 43}) teleported2 = teleport_function(self.conn, the_answer, the_globals) self.assertEqual(teleported2(), 43)
def test_globals(self): def the_answer(): return THE_ANSWER teleported = teleport_function(self.conn, the_answer) self.conn.namespace['THE_ANSWER'] = 42 self.assertEqual(teleported(), 42) the_globals = self.conn.builtins.dict({'THE_ANSWER': 43}) teleported2 = teleport_function(self.conn, the_answer, the_globals) self.assertEqual(teleported2(), 43)
def test(self): exp = export_function(f) f2 = import_function(exp) self.assertEqual(f(6)(7), f2(6)(7)) h2 = teleport_function(self.conn, h) self.assertNotEqual(h(7), h2(7))
def test(self): exp = export_function(f) f2 = import_function(exp) self.assertEqual(f(6)(7), f2(6)(7)) # HACK: needed so the other side could import us (for globals) mod = self.conn.modules.types.ModuleType(__name__) self.conn.modules.sys.modules[__name__] = mod mod.__builtins__ = self.conn.builtins h2 = teleport_function(self.conn, h) self.assertNotEqual(h(7), h2(7))
def juiceDeployment(host, loacalJuice, loaclJuiceHandler, localJuiceDataMerger): # create the deployment mach = SshMachine(host, user="******", keyfile="/home/zitongc2/.ssh/id_rsa") server = DeployedServer(mach) # and now you can connect to it the usual way conn = server.classic_connect() print("[INFO] Connected to ", host) conn._config['sync_request_timeout'] = None remoteJuice = conn.teleport(loacalJuice) remoteMapleHandler = teleport_function(conn, loaclJuiceHandler) remoteMapleHandler(remoteJuice) print("[INFO] Done processing, now sendind result to desinated location") remoteJuiceDataMerger = teleport_function(conn, localJuiceDataMerger) remoteJuiceDataMerger(socket.gethostbyname(socket.gethostname())) # when you're done - close the server and everything will disappear server.close()
def test_defaults(self): defaults_ = teleport_function(self.conn, defaults) self.assertEqual(defaults_(), defaults())
def test_def(self): foo_ = teleport_function(self.conn, foo) bar_ = teleport_function(self.conn, bar) self.assertEqual(foo_(), 43) self.assertEqual(bar_(), 42)
def test_kwdefaults(self): kwdefaults_ = teleport_function(self.conn, kwdefaults) self.assertEqual(kwdefaults_(), kwdefaults())