-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (31 loc) · 935 Bytes
/
main.py
File metadata and controls
46 lines (31 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging
import argparse
import yaml
import sys
from ecmwf import EcmwfApi
from bot import PlotBot
from logger_config import logger
from db import Database
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_level',
dest='log_level',
type=int,
default=logging.INFO,
choices=[logging.DEBUG, logging.INFO],
help=
f'set the logging level ({logging.DEBUG}: DEBUG, {logging.INFO}: INFO')
args = parser.parse_args()
logger.setLevel(args.log_level)
with open('stations.yaml', 'r') as file:
station_config = yaml.safe_load(file)
ecmwf = EcmwfApi(station_config)
config_file = 'config.yml'
db = Database(config_file)
bot = PlotBot(config_file, station_config, db=db, ecmwf=ecmwf)
bot.start()
# we only end up here if the bot had an error
sys.exit(1)
if __name__ == '__main__':
main()