def __init__(self, api_key, user_agent='Python HTB Client/{}'.format(__version__)): HTB.__init__(self, api_key, user_agent) self.headers['Authorization'] = f"Bearer {api_key}" HTB._validate_response = HTBAPI._validate_response
#!/usr/bin/env python3 from sys import argv, exit from os import environ from htb import HTB from prettytable import PrettyTable try: htb = HTB(environ["HTB_API_KEY"]) except: print("Setup the HTB_API_KEY first!") exit(1) def print_machine(argv): global htb mid = int(argv.pop()) machine = htb.get_machine(mid) for key, value in machine.items(): if key == "avatar" or key == "avatar_thumb": continue print(key.upper() + ": ", end="") if type(value) is dict: print() for k, v in value.items(): print("\t" + k.upper() + ": " + str(v)) else: print(str(value))
def test_global_stats(): api_key = 'test' client = HTB(api_key) assert client.global_stats()['success'] == '1'
def test___init__(): api_key = 'test' client = HTB(api_key) assert client.api_key == api_key
def test_daily_owns(): api_key = 'test' client = HTB(api_key) assert client.daily_owns()['success'] == '1'
def test_overview_stats(): api_key = 'test' client = HTB(api_key) assert len(client.overview_stats()) == 3