<commit_before>import requests


def get_task_by_id(auth_cookies, id):
    resp = requests.get('http://141.20.26.37:8080/api/v1/tasks?id=55', cookies=auth_cookies)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    print(resp.json())


def get_task_ids(auth_cookies):
    task_id_list = list()

    resp = requests.get('http://141.20.26.37:8080/api/v1/tasks', cookies=auth_cookies)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    json_response = resp.json()
    next_page = json_response['next']
    print(next_page)

    for entry in json_response['results']:
        task_id_list.append(entry['id'])

    while next_page is not None:
        resp = requests.get(next_page, cookies=auth_cookies)
        if resp.status_code != 200:
            # This means something went wrong.
            print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

        json_response = resp.json()
        next_page = json_response['next']
        print(next_page)

        for entry in json_response['results']:
            task_id_list.append(entry['id'])

    print(task_id_list)


if __name__ == "__main__":
    # TODO get username and password via argparse
    data = {'username': 'benji', 'password': '<PASSWORD>'}

    resp = requests.post('http://141.20.26.37:8080/api/v1/auth/login', data=data)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    auth_cookies = resp.cookies

    get_task_ids(auth_cookies)
<commit_msg>wip for cvat api stuff<commit_after>import requests


def get_task_by_id(auth_cookies, id):
    resp = requests.get('http://192.168.127.12:8080/api/v1/tasks?id=55', cookies=auth_cookies)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    print(resp.json())


def get_task_ids(auth_cookies):
    task_id_list = list()

    resp = requests.get('http://192.168.127.12:8080/api/v1/tasks', cookies=auth_cookies)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    json_response = resp.json()
    next_page = json_response['next']
    print(next_page)

    for entry in json_response['results']:
        task_id_list.append(entry['id'])

    while next_page is not None:
        resp = requests.get(next_page, cookies=auth_cookies)
        if resp.status_code != 200:
            # This means something went wrong.
            print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

        json_response = resp.json()
        next_page = json_response['next']
        print(next_page)

        for entry in json_response['results']:
            task_id_list.append(entry['id'])

    print(task_id_list)


def get_frame(auth_cookies):
    from PIL import Image
    from PIL import PngImagePlugin
    from io import BytesIO
    resp = requests.get("http://141.20.26.37:8080/api/v1/tasks/56/frames/1", cookies=auth_cookies)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    im = Image.open(BytesIO(resp.content))
    outfile = 'blub.png'
    im.save(outfile)
    # im.save(filename, pnginfo=meta)


if __name__ == "__main__":
    # TODO get username and password via argparse
    data = {'username': 'benji', 'password': '<PASSWORD>'}

    resp = requests.post('http://141.20.26.37:8080/api/v1/auth/login', data=data)
    if resp.status_code != 200:
        # This means something went wrong.
        print("HTTP %i - %s, Message %s" % (resp.status_code, resp.reason, resp.text))

    auth_cookies = resp.cookies

    get_task_ids(auth_cookies)
    get_frame(auth_cookies)

{'fraction_non_alphanumeric': 0.13696969696969696, 'fraction_numerical': 0.03296969696969697, 'mean_word_length': 3.0058252427184464, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 7, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4251370', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1368, 'n_words': 305}