diff --git a/database_caller.py b/database_caller.py index f9242fe..e2db9d7 100755 --- a/database_caller.py +++ b/database_caller.py @@ -282,9 +282,11 @@ def updateWeather(api_key): all_locations = list(set(current_locations + daily_locations)) + - current_list = [] - daily_list = [] + + current_weathers = {} + daily_weathers = {} @@ -315,7 +317,7 @@ def updateWeather(api_key): if location in current_locations: - current_list.append(current_weather) + current_weathers[location] = current_weather daily_weather = [] daily = r.json()['daily'] @@ -340,16 +342,10 @@ def updateWeather(api_key): daily_weather[0]['visibility'] = current_weather['visibility'] if location in daily_locations: - daily_list.append(daily_weather) + daily_weathers[location] = daily_weather + - current_weathers = {} - daily_weathers = {} - for i,loc in enumerate(current_locations): - current_weathers[loc] = current_list[i] - - for i,loc in enumerate(daily_locations): - daily_weathers[loc] = daily_list[i] all_current_settings['locations'] = current_weathers all_daily_settings['locations'] = daily_weathers @@ -588,7 +584,7 @@ if __name__ == '__main__': - update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes + update_frequencies = {'stocks':1, 'crypto':1, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes NY_zone = pytz.timezone('America/New_York') CET_zone = pytz.timezone('EST') @@ -677,6 +673,8 @@ if __name__ == '__main__': NY_time = datetime.now(NY_zone).replace(tzinfo=None) diff = (NY_time - crypto_time).total_seconds()/60 #minutes + + if diff >= update_frequencies['crypto'] or msg == 'c': crypto_time = NY_time.strftime("%d/%m/%Y %H:%M:%S") #updateCrypto(api_key) diff --git a/stockTicker.py b/stockTicker.py index 879e642..9609a2c 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -1688,7 +1688,7 @@ class StockTicker(): img = img.crop((0,0,x_offset ,32)) imgs.append(img) except Exception as e: - raise e + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] self.logf.write(str(e)) @@ -1787,7 +1787,7 @@ class StockTicker(): img = img.crop((0,0,x_offset ,32)) imgs.append(img) except Exception as e: - raise e + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] self.logf.write(str(e)) @@ -2756,7 +2756,7 @@ if __name__ == '__main__': #stock_ticker.process_msg('-') #stock_ticker.process_msg('W') - stock_ticker.process_msg('A') + #stock_ticker.process_msg('A') @@ -2764,7 +2764,7 @@ if __name__ == '__main__': msg = getInput() stock_ticker.process_msg(msg) except Exception as e: - raise e + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] log.write(str(e))