icalendar-timeseries-server/icalendar_timeseries_server/main.py

28 lines
806 B
Python

import sys
import bottle
from icalendar_timeseries_server.cal import scrape_calendar
from icalendar_timeseries_server.config import load_config, load_default_config, get_config
# Contains decorated bottle handler function for /api/v1/query
# noinspection PyUnresolvedReferences
from icalendar_timeseries_server.api import prometheus_api
def main():
if len(sys.argv) == 1:
load_default_config()
elif len(sys.argv) == 2:
load_config(sys.argv[1])
else:
print(f'Can only read one config file, got "{" ".join(sys.argv[1:])}"')
exit(1)
config = get_config()
for calname in config.calendars.keys():
scrape_calendar(calname, config.calendars[calname])
bottle.run(host=config.addr, port=get_config().port)
if __name__ == '__main__':
main()