Browse Source

Add time to console, reset count at new day

pull/2/head
Jxck-S 4 years ago
parent
commit
4cba3706da
  1. 15
      NotifyBotMulti.py
  2. 4
      mainconf.ini

15
NotifyBotMulti.py

@ -5,6 +5,8 @@ import time
from defADSBX import pullADSBX
from colorama import Fore, Back, Style
from planeClass import Plane
from datetime import datetime
import pytz
main_config = configparser.ConfigParser()
main_config.read('mainconf.ini')
import os
@ -20,10 +22,18 @@ if main_config.get('DATA', 'SOURCE') == "ADSBX":
elif main_config.get('DATA', 'SOURCE') == "OPENS":
raise NotImplementedError
running_Count = 0
try:
tz = pytz.timezone(main_config.get('DATA', 'TZ'))
except pytz.exceptions.UnknownTimeZoneError:
tz = pytz.UTC
while True:
datetime_tz = datetime.now(tz)
if datetime_tz.hour == 0 and datetime_tz.minute == 0:
running_Count = 0
running_Count +=1
start_time = time.time()
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "-------------------------------------------------------", Style.RESET_ALL)
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "--------", datetime_tz.strftime("%I:%M:%S %p"), "-------------------------------------------------------", Style.RESET_ALL)
if main_config.get('DATA', 'SOURCE') == "ADSBX":
data, failed = pullADSBX(planes)
if failed == False:
@ -41,7 +51,8 @@ while True:
for obj in planes.values():
obj.run(None)
elapsed_calc_time = time.time() - start_time
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "------------------------Elapsed Time-", elapsed_calc_time, " -------------------------------------", Style.RESET_ALL)
datetime_tz = datetime.now(tz)
print (Back.GREEN, Fore.BLACK, "--------", running_Count, "--------", datetime_tz.strftime("%I:%M:%S %p"), "------------------------Elapsed Time-", elapsed_calc_time, " -------------------------------------", Style.RESET_ALL)
print(Back.RED, "Sleep 30", Style.RESET_ALL)
time.sleep(30)

4
mainconf.ini

@ -5,6 +5,10 @@
#ADS-B Exchange has better data but is not avalible unless you feed their network or pay.
SOURCE = ADSBX
#Timezone if you want your own time to show in the console, if invalid will be set to UTC.
#List of TZs names https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TZ = UTC
#ADS-B Exchange https://www.adsbexchange.com/data/
[ADSBX]
API_KEY = apikey

Loading…
Cancel
Save