trial of new databasecaller method
This commit is contained in:
@@ -43,7 +43,7 @@ def updateUpdate(NY_time):
|
||||
|
||||
|
||||
|
||||
def updateStocks(api_key):
|
||||
def updateStocks(api_key, logf):
|
||||
|
||||
|
||||
try:
|
||||
@@ -95,8 +95,8 @@ def updateStocks(api_key):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateCrypto(api_key):
|
||||
|
||||
def updateCrypto(api_key, logf):
|
||||
|
||||
|
||||
#cypto_info['symbol, base'].keys() = ['current','24hr change']
|
||||
try:
|
||||
@@ -122,6 +122,7 @@ def updateCrypto(api_key):
|
||||
print(url)
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
print(url)
|
||||
print(data)
|
||||
|
||||
|
||||
@@ -138,11 +139,12 @@ def updateCrypto(api_key):
|
||||
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr']}
|
||||
|
||||
all_crypto_settings['symbols'] = coin_info
|
||||
|
||||
json.dump(all_crypto_settings, open('csv/crypto_settings.json', 'w+'))
|
||||
f = open('csv/crypto_settings.json', 'w+')
|
||||
json.dump(all_crypto_settings, f)
|
||||
f.close()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||
logf.write(str(e))
|
||||
@@ -151,7 +153,7 @@ def updateCrypto(api_key):
|
||||
logf.write('. type: ' + str(exc_type))
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
def updateForex(api_key):
|
||||
def updateForex(api_key, logf):
|
||||
|
||||
|
||||
|
||||
@@ -206,7 +208,7 @@ def updateForex(api_key):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateNews(api_key):
|
||||
def updateNews(api_key, logf):
|
||||
|
||||
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?category=technology'
|
||||
#'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country=GB'
|
||||
@@ -263,7 +265,7 @@ def updateNews(api_key):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateWeather(api_key):
|
||||
def updateWeather(api_key, logf):
|
||||
max_cities = 30
|
||||
|
||||
try:
|
||||
@@ -363,7 +365,7 @@ def updateWeather(api_key):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateLeagueTables(api_key):
|
||||
def updateLeagueTables(api_key, logf):
|
||||
|
||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?stats='
|
||||
try:
|
||||
@@ -428,7 +430,7 @@ def updateLeagueTables(api_key):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateLeagueEvents(api_key, time):
|
||||
def updateLeagueEvents(api_key, time, logf):
|
||||
|
||||
url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/sports?{}='.format(time)
|
||||
|
||||
@@ -507,14 +509,14 @@ def updateLeagueEvents(api_key, time):
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
def updateSports(api_key):
|
||||
def updateSports(api_key, logf):
|
||||
#read user settings to decide which sprots to update
|
||||
|
||||
updateLeagueTables(api_key)
|
||||
updateLeagueTables(api_key, logf)
|
||||
|
||||
updateLeagueEvents(api_key,'livescore')
|
||||
updateLeagueEvents(api_key,'past')
|
||||
updateLeagueEvents(api_key,'upcoming')
|
||||
updateLeagueEvents(api_key,'livescore', logf)
|
||||
updateLeagueEvents(api_key,'past', logf)
|
||||
updateLeagueEvents(api_key,'upcoming', logf)
|
||||
|
||||
|
||||
|
||||
@@ -560,19 +562,19 @@ def checkStocks(last_update, update_frequency):
|
||||
return updated
|
||||
|
||||
|
||||
def updateAll(api_key, weather_key):
|
||||
updateStocks(api_key)
|
||||
def updateAll(api_key, weather_key, logf):
|
||||
updateStocks(api_key, logf)
|
||||
|
||||
updateCrypto(api_key)
|
||||
updateCrypto(api_key, logf)
|
||||
|
||||
updateForex(api_key)
|
||||
updateForex(api_key, logf)
|
||||
|
||||
updateNews(api_key)
|
||||
updateNews(api_key, logf)
|
||||
|
||||
updateSports(api_key)
|
||||
updateSports(api_key, logf)
|
||||
|
||||
if weather_key:
|
||||
updateWeather(weather_key)
|
||||
updateWeather(weather_key, logf)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -584,7 +586,7 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
update_frequencies = {'stocks':1, 'crypto':1, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes
|
||||
update_frequencies = {'stocks':1, 'crypto':1, 'forex':1, 'news':1, 'weather': 1, 'sports': 1} #minutes
|
||||
|
||||
NY_zone = pytz.timezone('America/New_York')
|
||||
CET_zone = pytz.timezone('EST')
|
||||
@@ -641,7 +643,7 @@ if __name__ == '__main__':
|
||||
|
||||
msg = getInput()
|
||||
if msg == 'A':
|
||||
update_process = Process(target = updateAll, args = (api_key,weather_key))
|
||||
update_process = Process(target = updateAll, args = (api_key,weather_key, logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
stock_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
@@ -663,7 +665,7 @@ if __name__ == '__main__':
|
||||
stock_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
last_updates['stocks'] = stock_time
|
||||
#updateStocks(api_key)
|
||||
update_process = Process(target = updateStocks, args = (api_key,))
|
||||
update_process = Process(target = updateStocks, args = (api_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -678,8 +680,10 @@ if __name__ == '__main__':
|
||||
if diff >= update_frequencies['crypto'] or msg == 'c':
|
||||
crypto_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
#updateCrypto(api_key)
|
||||
print('UPDATING CRYPTO')
|
||||
|
||||
last_updates['crypto'] = crypto_time
|
||||
update_process = Process(target = updateCrypto, args = (api_key,))
|
||||
update_process = Process(target = updateCrypto, args = (api_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -695,7 +699,7 @@ if __name__ == '__main__':
|
||||
|
||||
#updateWeather(weather_key)
|
||||
last_updates['weather'] = weather_time
|
||||
update_process = Process(target = updateWeather, args = (weather_key,))
|
||||
update_process = Process(target = updateWeather, args = (weather_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -710,7 +714,7 @@ if __name__ == '__main__':
|
||||
news_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
#updateNews(api_key)
|
||||
last_updates['news'] = news_time
|
||||
update_process = Process(target = updateNews, args = (api_key,))
|
||||
update_process = Process(target = updateNews, args = (api_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -722,7 +726,7 @@ if __name__ == '__main__':
|
||||
sports_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
#updateSports(api_key)
|
||||
last_updates['sports'] = sports_time
|
||||
update_process = Process(target = updateSports, args = (api_key,))
|
||||
update_process = Process(target = updateSports, args = (api_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -743,7 +747,7 @@ if __name__ == '__main__':
|
||||
forex_time = CET_time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
last_updates['forex'] = forex_time
|
||||
#updateForex(api_key)
|
||||
update_process = Process(target = updateForex, args = (api_key,))
|
||||
update_process = Process(target = updateForex, args = (api_key,logf))
|
||||
update_process.start()
|
||||
update_processes.append(update_process)
|
||||
|
||||
@@ -753,9 +757,11 @@ if __name__ == '__main__':
|
||||
if not process.is_alive():
|
||||
process.join()
|
||||
process.terminate()
|
||||
update_processes.remove(process)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||
logf.write(str(e))
|
||||
@@ -764,5 +770,6 @@ if __name__ == '__main__':
|
||||
logf.write('. type: ' + str(exc_type))
|
||||
logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user