Esempio n. 1
0
def bamboo_store_csv_file(csv_file, bamboo_url):
    files = {"csv_file": ('data.csv', open(csv_file))}
    req = requests.post(bamboo_url, files=files)
    if not req.status_code in (200, 201, 202):
        raise ErrorRetrievingBambooData(u"%d Status Code received."
                                        % req.status_code)
    return load_json(req.text)
Esempio n. 2
0
def bamboo_query(report,
                 select=None, query=None, group=None,
                 as_summary=False,
                 first=False, last=False,
                 print_url=False):

    params = {
        'select': select,
        'query': query,
        'group': group
    }

    # remove key with no value
    for key, value in params.items():
        if not value:
            params.pop(key)
        else:
            if isinstance(value, dict):
                params[key] = dump_json(value)

    if as_summary:
        url = get_bamboo_dataset_summary_url(report)
    else:
        url = get_bamboo_dataset_url(report)

    req = requests.get(url, params=params)

    print req.url
    # debugging
    if print_url:
        print(req.url)

    if not req.status_code in (200, 202):
        raise ErrorRetrievingBambooData(u"%d Status Code received."
                                        % req.status_code)

    try:
        response = load_json(req.text)
        if last:
            return response[-1]
        elif first:
            return response[0]
        else:
            return response 
    except Exception as e:
        print(req.text)
        raise ErrorParsingBambooData(e.message)
Esempio n. 3
0
def bamboo_store_calculation(report, formula_name, formula):

    url = get_bamboo_dataset_calculations_url(report)

    params = {'name': formula_name,
              'formula': formula}

    req = requests.post(url, params=params)

    if not req.status_code in (200, 201, 202):
        raise ErrorRetrievingBambooData(u"%d Status Code received."
                                        % req.status_code)

    try:
        return load_json(req.text)
    except Exception as e:
        print(req.text)
        raise ErrorParsingBambooData(e.message)