Exemplo n.º 1
0
def remove_documentation(task, request, project_name):
    request.log.info("Removing documentation for %s", project_name)
    storage = request.find_service(IDocsStorage)
    try:
        storage.remove_by_prefix(f"{project_name}/")
    except Exception as exc:
        task.retry(exc=exc)
Exemplo n.º 2
0
def remove_documentation(task, request, project_name):
    request.log.info("Removing documentation for %s", project_name)
    storage = request.find_service(IDocsStorage)
    try:
        storage.remove_by_prefix(project_name)
    except Exception as exc:
        task.retry(exc=exc)
Exemplo n.º 3
0
def run_check(task,
              request,
              check_name,
              obj_id=None,
              manually_triggered=False):
    try:
        check = getattr(checks, check_name)(request.db)
    except NoResultFound:
        request.log.info("Check %s isn't active. Aborting." % check_name)
        return

    # Don't run scheduled checks if they are in evaluation mode, unless manually
    # triggered.
    if check.state == MalwareCheckState.Evaluation and not manually_triggered:
        request.log.info(
            "%s is in the `evaluation` state and must be manually triggered to run."
            % check_name)
        return

    kwargs = {}

    # Hooked checks require `obj_id`s.
    if obj_id is not None:
        kwargs = check.prepare(request, obj_id)

    try:
        check.run(**kwargs)
    except FatalCheckException as exc:
        request.log.error("Fatal exception: %s: %s" % (check_name, str(exc)))
        return
    except Exception as exc:
        request.log.error("Error executing check %s: %s" %
                          (check_name, str(exc)))
        raise task.retry(exc=exc)