Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
 def recieve(self, arguments):
     invoked_func_name = arguments["invoked_func_name"]
     codes = arguments["codes"]
     arg = arguments["arg"]
     kw = arguments["kw"]
     options = arguments["options"]
     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()
Ejemplo n.º 4
0
 def _recieve(self, arguments, dirname):
     invoked_func_name = arguments["invoked_func_name"]
     codes = arguments["codes"]
     arg = arguments["arg"]
     kw = arguments["kw"]
     options = arguments["options"]
     chrome = self.gen_chrome(options, dirname)
     metadata = {'status': 'success'}
     try:
         for name, code in codes.items():
             func = self.parse_code(code, name)
             setattr(chrome, name, types.MethodType(func, chrome))
         response = getattr(chrome, invoked_func_name)(*arg, **kw)
     except Exception:
         metadata['status'] = 'error'
         response = "\n".join([
             "\n============== CHROMELESS TRACEBACK IN LAMBDA START ==============",
             traceback.format_exc(),
             "============== CHROMELESS TRACEBACK IN LAMBDA END ================\n",
         ])
     finally:
         chrome.quit()
     return dumps((response, metadata))