forked from dankolbrs/forecastio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forecast.py
executable file
·28 lines (23 loc) · 1.17 KB
/
forecast.py
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
#! /usr/bin/env python
from lib.forecastio import ForecastIO
from lib.influxdbwrap import InfluxDBWrapper
import configargparse
import os
p = configargparse.ArgParser(default_config_files=[
str(os.path.dirname(__file__)) + '/config.ini'])
p.add('-c', "--config", is_config_file=True, help="Config file path")
p.add("-a", "--apikey", required=True, help="ForecastIO apikey")
p.add("-t", "--lat", required=True, help="Latitude for weather forecast")
p.add("-n", "--lon", required=True, help="Longitude for weather forecast")
p.add("-o", "--host", required=False, help="Influxdb host")
p.add("-p", "--port", required=False, help="Influxdb port")
p.add("-u", "--username", required=False, help="Influxdb username")
p.add("-i", "--password", required=False, help="Influxdb password")
p.add("-d", "--database", required=False, help="Influxdb database")
options = p.parse_args()
forecast = ForecastIO(options.apikey, options.lat, options.lon)
influx_db_wrap = InfluxDBWrapper(options.host,
options.port, options.username,
options.password, options.database)
current = forecast.get_current()
influx_db_wrap.insert_current(current)