def recieve(self, dumped): invoked_func_name, codes, arg, kw, options = loads(dumped) chrome = self.gen_chrome(options) for name, code in codes.items(): func = self.parse_code(code, name) setattr(chrome, name, types.MethodType(func, chrome)) try: return dumps(getattr(chrome, invoked_func_name)(*arg, **kw)) except Exception: raise finally: chrome.quit()
def invoke(dumped): arg = loads(dumped) print(arg) required_version = arg['REQUIRED_SERVER_VERSION'] if isinstance( arg, dict) else None ChormelessServerClass = { 2: ChromelessServer, # latest 1: ChromelessServerVer1, None: ChromelessServerVerNone, }[required_version] if required_version is None: arg = dumps(arg) # dump again return ChormelessServerClass().recieve(arg)
from server import handler from picklelib import loads, dumps from time import sleep if __name__ == '__main__': with open('/data/dumped.txt', 'r') as f: dumped = f.read() event = {'dumped': dumped} print(loads(handler(event)))