def __init__(self): self.config = APIConfig() self.conn = MySQLdb.connect( self.config.sql_server, self.config.sql_user, self.config.sql_password, self.config.sql_database) self.conn.autocommit(True)
from logger import Logger log = Logger('logAgregator.txt') log.lprint("WeatherDataAgregator --- START") #-------------- # setup weather APIs #-------------- log.lprint("setup weather APIs") if not os.path.exists(file_path+'openweathermap.conf'): log.lprint("conf files missing!") quit() conf = APIConfig() conf.loadFromFile(file_path+'wettercom.conf') wCom = WetterCom(conf) conf2 = APIConfig() conf2.loadFromFile(file_path+'openweathermap.conf') owm = OpenWeatherMap(conf2) conf3 = APIConfig() conf3.loadFromFile(file_path+'forecastio.conf') fio = ForecastIOAPI(conf3) #-------------- # get forecasts #-------------- log.lprint("get forecasts")
from logger import Logger log = Logger('logChecker.txt') log.lprint("WeatherDataChecker --- START") if not os.path.exists(file_path+'wettercomDump.pkl'): log.lprint("dump files missing! - quit!") quit() #-------------- # setup weather API for current weather data #-------------- log.lprint("set up weather APIs") conf = APIConfig() conf.loadFromFile(file_path+'openweathermap.conf') owm = OpenWeatherMap(conf) fio = ForecastIOAPI(conf) wcom = WetterCom(conf) #-------------- # get weather data #-------------- log.lprint("get current weather") owm.getCurrentData() current_data = dm.WeatherSamplePoint(owm.current_weather.date, owm.current_weather.time) current_data.copyData(owm.current_weather) #-------------- # load time series data from file
from logger import Logger log = Logger('logChecker.txt') log.lprint("WeatherDataChecker --- START") if not os.path.exists(file_path + 'wettercomDump.pkl'): log.lprint("dump files missing! - quit!") quit() #-------------- # setup weather API for current weather data #-------------- log.lprint("set up weather APIs") conf = APIConfig() conf.loadFromFile(file_path + 'openweathermap.conf') owm = OpenWeatherMap(conf) fio = ForecastIOAPI(conf) wcom = WetterCom(conf) #-------------- # get weather data #-------------- log.lprint("get current weather") owm.getCurrentData() current_data = dm.WeatherSamplePoint(owm.current_weather.date, owm.current_weather.time) current_data.copyData(owm.current_weather) #--------------