def main():
    '\n    main function collecting data from input file/storage and serving prometheus data\n    '
    import argparse
    parser = argparse.ArgumentParser(description='Convert data received from alfred and provide them as prometheus-service')
    parser.add_argument('-m', '--maps', default='robin.txt', help='input file containing data collected by alfred')
    parser.add_argument('--storage', default='nodes_backup.bin', help='store old data between calls e.g. to remember node lastseen values')
    parser.add_argument('-p', '--port', default=8000, help='the port this service should listen to')
    args = parser.parse_args()
    nodes = {}
    if is_file(args.storage):
        nodes = load_nodes(args.storage)
    remove_old_nodes(nodes, datetime.timedelta(days=7))
    try:
        with open(args.maps, 'r') as maps:
            for line in maps.readlines():
                try:
                    AlfredParser.parse_line(line.strip(), nodes)
                except:
                    import traceback
                    print(line)
                    traceback.print_exc()
                    continue
        nodes_json = render_nodelist(nodes)
    except IOError:
        exit((('File ' + args.maps) + ' not accessible'))
    if args.storage:
        save_nodes(args.storage, nodes)
    global GLOBAL_NODES
    GLOBAL_NODES = nodes_json
    global PORT_NUMBER
    try:
        PORT_NUMBER = int(args.port)
    except ValueError:
        exit((('Error: ' + args.port) + ' is not a valid port-number'))
main function collecting data from input file/storage and serving prometheus data
def main():
    '\n    \n    '
    import argparse
    parser = argparse.ArgumentParser(description='Convert data received from alfred and provide them as prometheus-service')
    parser.add_argument('-m', '--maps', default='robin.txt', help='input file containing data collected by alfred')
    parser.add_argument('--storage', default='nodes_backup.bin', help='store old data between calls e.g. to remember node lastseen values')
    parser.add_argument('-p', '--port', default=8000, help='the port this service should listen to')
    args = parser.parse_args()
    nodes = {}
    if is_file(args.storage):
        nodes = load_nodes(args.storage)
    remove_old_nodes(nodes, datetime.timedelta(days=7))
    try:
        with open(args.maps, 'r') as maps:
            for line in maps.readlines():
                try:
                    AlfredParser.parse_line(line.strip(), nodes)
                except:
                    import traceback
                    print(line)
                    traceback.print_exc()
                    continue
        nodes_json = render_nodelist(nodes)
    except IOError:
        exit((('File ' + args.maps) + ' not accessible'))
    if args.storage:
        save_nodes(args.storage, nodes)
    global GLOBAL_NODES
    GLOBAL_NODES = nodes_json
    global PORT_NUMBER
    try:
        PORT_NUMBER = int(args.port)
    except ValueError:
        exit((('Error: ' + args.port) + ' is not a valid port-number'))