<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cmd_cymon_ip_timeline(ip, no_cache, verbose, output, pretty):
 """Simple cymon API client. Prints the JSON result of a cymon IP timeline query. Example: \b $ habu.cymon.ip.timeline 8.8.8.8 { "timeline": [ { "time_label": "Aug. 18, 2018", "events": [ { "created": "2018-08-18T21:39:07Z", "title": "Malicious activity reported by urlquery.net", "details_url": "http://urlquery.net/report/b1393866-9b1f-4a8e-b02b-9636989050f3", "tag": "malicious activity" } ] }, """


    habucfg = loadcfg()

    if 'CYMON_APIKEY' not in habucfg:
        print('You must provide a cymon apikey. Use the ~/.habu.json file (variable CYMON_APIKEY), or export the variable HABU_CYMON_APIKEY')
        print('Get your API key from https://www.cymon.io/')
        sys.exit(1)

    if verbose:
        logging.basicConfig(level=logging.INFO, format='%(message)s')

    if not no_cache:
        homedir = pwd.getpwuid(os.getuid()).pw_dir
        requests_cache.install_cache(homedir + '/.habu_requests_cache')

    url = 'https://www.cymon.io:443/api/nexus/v1/ip/{}/timeline/'.format(ip)
    headers = { 'Authorization': 'Token {}'.format(habucfg['CYMON_APIKEY']) }

    r = requests.get(url, headers=headers)

    if r.status_code not in [200, 404]:
        print('ERROR', r)
        return False

    if r.status_code == 404:
        print("Not Found")
        return False

    data = r.json()

    if pretty:
        output.write(pretty_print(data))
    else:
        output.write(json.dumps(data, indent=4))
        output.write('\n')