Exemple #1
0
 def bugzilla(cls):
     if not hasattr(cls, "_bugzilla"):
         try:
             cls._bugzilla = Bugzilla.from_config()
         except KeyError:
             return None
     return cls._bugzilla
Exemple #2
0
def get_report(directory, include_manual=True):
    bz_instance = Bugzilla.from_config()
    if not (bz_instance.user or bz_instance.key):
        msg = ("ERROR: Credentials key for bugzilla does not have username or api key.")
        click.secho(msg, err=True, bold=True, fg="red")
        sys.exit(0)
    click.echo("Generating a BZ report in bz-report.yaml")
    options = ["--use-provider", "complete",
        "--long-running",
        "--use-template-cache",
        "--collect-only",
        "--dummy-appliance",
        "-q",
        "--generate-bz-report"
               ]
    if include_manual:
        options.append("--include-manual")
    pytest.main(options.append(directory))
    # read the generated yaml
    try:
        with open("bz-report.yaml") as stream:
            info = yaml.load(stream, Loader=yaml.BaseLoader)
    except OSError:
        msg = (
            "ERROR: File bz-report.yaml not found, something went wrong during report generation.\n"
            "       Likely no BZs were found in {} with 'automates'/'coverage',"
            " so a report wasn't generated.".format(directory)
        )
        click.secho(msg, err=True, bold=True, fg="red")
        sys.exit(0)
    return info
Exemple #3
0
def check_query(request):
    if not request.user.is_authenticated():
        return go_home(request)
    if request.method != 'POST':
        return HttpResponseForbidden('Only POST allowed')
    bz = Bugzilla.from_config().bugzilla
    try:
        parsed = bz.url_to_query(request.POST['url'])
        if not parsed:
            parsed = None
    except:
        parsed = None
    if 'cmdtype' in parsed:
        # It is a command and that is not supported within .query()
        parsed = None
    return json_response(parsed)
Exemple #4
0
def check_query(request):
    if not request.user.is_authenticated():
        return go_home(request)
    if request.method != 'POST':
        return HttpResponseForbidden('Only POST allowed')
    bz = Bugzilla.from_config().bugzilla
    try:
        parsed = bz.url_to_query(request.POST['url'])
        if not parsed:
            parsed = None
    except Exception:
        parsed = None
    if 'cmdtype' in parsed:
        # It is a command and that is not supported within .query()
        parsed = None
    return json_response(parsed)
 def bugzilla(cls):
     if not hasattr(cls, "_bugzilla"):
         cls._bugzilla = Bugzilla.from_config()
     return cls._bugzilla