def main():
    parser = ConfigParser()
    parser.read('config-demo.ini')
    device_list_file = parser['backups']['device_list']
    apikey = parser['confluence']['apikey']
    username = parser['confluence']['username']
    url = parser['confluence']['url']
    page_ID = parser['confluence']['page_ID']
    confluence = Confluence(url=url, username=username, password=apikey)
    with open(device_list_file) as file:
        lines = file.readlines()
        devices = [line.rstrip() for line in lines]
    wiki_table = '||Device||Date||'
    for device in devices:
        device_bkp = Backup(device, parser['backups']['path'])
        latest_bkp_date = device_bkp.latest()
        print(f'Latest backup for {device_bkp.name()} is {latest_bkp_date}')
        wiki_table += ('\n' + f'|{device}|{latest_bkp_date}|')
    print('Wiki text for table is:')
    print(wiki_table)
    result = confluence.update_page(page_id=page_ID, title='Config Retrievals', representation='wiki', body=wiki_table)
    print(f"Title of page set to '{result['title']}'")
    print(f"Confluence revision for page is now {result['version']['confRev']}")
def main():
    parser = ConfigParser()
    parser.read('config-demo.ini')
    device_list_file = parser['backups']['device_list']
    apikey = parser['confluence']['apikey']
    username = parser['confluence']['username']
    url = parser['confluence']['url']
    page_ID = parser['confluence']['page_ID']
    confluence = Confluence(url=url, username=username, password=apikey)
    with open(device_list_file) as file:
        lines = file.readlines()
        devices = [line.rstrip() for line in lines]
    wiki_table = '||Device||Date||'
    for device in devices:
        device_bkp = Backup(device, parser['backups']['path'])
        latest_bkp_date = device_bkp.latest()
        print(f'Latest backup for {device_bkp.name()} is {latest_bkp_date}')
        wiki_table += ('\n' + f'|{device}|{latest_bkp_date}|')
    print('Wiki text for table is:')
    print(wiki_table)
    result = confluence.update_page(page_id=page_ID, title='Config Retrievals', representation='wiki', body=wiki_table)
    print(f"Title of page set to '{result['title']}'")
    print(f"Confluence revision for page is now {result['version']['confRev']}")