Пример #1
0
 def run(self, resource, *args, **kwargs):
     log.debug("Solard run: %s", args)
     client = self.get_client(resource)
     try:
         res = client.run(' '.join(args), **kwargs)
         return self.get_result(res, failed=False)
     except Exception as ex:
         log.exception("Exception during solard run")
         return self.get_result(ex, failed=True)
Пример #2
0
 def _async_event(self, event):
     try:
         if event.name not in self._methods:
             raise NameError(event.name)
         self._context.hook_load_task_context(event.header)
         self._context.hook_server_before_exec(event)
         self._methods[event.name](*event.args)
         # In Push/Pull their is no reply to send, hence None for the
         # reply_event argument
         self._context.hook_server_after_exec(event, None)
     except Exception:
         exc_infos = sys.exc_info()
         try:
             log.exception('')
             self._context.hook_server_inspect_exception(
                 event, None, exc_infos)
         finally:
             del exc_infos
Пример #3
0
 def _async_event(self, event):
     try:
         if event.name not in self._methods:
             raise NameError(event.name)
         self._context.hook_load_task_context(event.header)
         self._context.hook_server_before_exec(event)
         self._methods[event.name](*event.args)
         # In Push/Pull their is no reply to send, hence None for the
         # reply_event argument
         self._context.hook_server_after_exec(event, None)
     except Exception:
         exc_infos = sys.exc_info()
         try:
             log.exception('')
             self._context.hook_server_inspect_exception(
                 event, None, exc_infos)
         finally:
             del exc_infos
Пример #4
0
def validate_input(value, jsonschema=None, schema=None):
    """Validate single input according to schema.

    :param value: Value to be validated
    :param schema: Dict in jsonschema format
    :param schema: Our custom, simplified schema
    :return: list with errors
    """
    if jsonschema is None:
        jsonschema = construct_jsonschema(schema)
    try:
        validate(value, jsonschema)
    except ValidationError as e:
        return [e.message]
    except Exception as e:
        log.error('jsonschema: %s', jsonschema)
        log.error('value: %s', value)
        log.exception(e)
        raise