prepared for cli args
This commit is contained in:
+13
-7
@@ -6,6 +6,7 @@ from wci import wci
|
|||||||
from credentials import users
|
from credentials import users
|
||||||
from folder_mgr.folder_mgr import get_date, date_has_changed, FolderMgr, create_timestamp
|
from folder_mgr.folder_mgr import get_date, date_has_changed, FolderMgr, create_timestamp
|
||||||
from jay_diff import jay_diff_full
|
from jay_diff import jay_diff_full
|
||||||
|
import argparse
|
||||||
|
|
||||||
INTERVAL = 1*60
|
INTERVAL = 1*60
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ class WeCollector:
|
|||||||
print(f"Exception: {e}")
|
print(f"Exception: {e}")
|
||||||
|
|
||||||
|
|
||||||
def request_loop(_wc_list: list[WeCollector]):
|
def request_loop(wc: WeCollector):
|
||||||
_date_last = None
|
_date_last = None
|
||||||
_file_timestamp = None
|
_file_timestamp = None
|
||||||
|
|
||||||
@@ -106,13 +107,11 @@ def request_loop(_wc_list: list[WeCollector]):
|
|||||||
_file_timestamp = create_timestamp(with_ms=False).replace(':', '-').replace('.', '-')
|
_file_timestamp = create_timestamp(with_ms=False).replace(':', '-').replace('.', '-')
|
||||||
|
|
||||||
# Request service
|
# Request service
|
||||||
for wc in wc_list:
|
|
||||||
wc.init(_file_timestamp)
|
wc.init(_file_timestamp)
|
||||||
|
|
||||||
# Request service
|
# Request service
|
||||||
_date = get_date()
|
_date = get_date()
|
||||||
timestamp = create_timestamp()
|
timestamp = create_timestamp()
|
||||||
for wc in wc_list:
|
|
||||||
wc.request(_date, timestamp)
|
wc.request(_date, timestamp)
|
||||||
|
|
||||||
# wait until next loop
|
# wait until next loop
|
||||||
@@ -125,13 +124,20 @@ def request_loop(_wc_list: list[WeCollector]):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
wc_list = []
|
parser = argparse.ArgumentParser(prog="We Collect", description="Collects vehicle data")
|
||||||
|
parser.add_argument("username", help="Username to collect data for (must exist in credentials.py)")
|
||||||
|
parser.add_argument("--loop", help="Execute once or create event loop", type=bool, default=False)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
print(args)
|
||||||
|
|
||||||
|
wc = None
|
||||||
for user in users:
|
for user in users:
|
||||||
wc_list.append(WeCollector(user))
|
if args.username in user['username']:
|
||||||
|
wc = WeCollector(user)
|
||||||
|
|
||||||
print(wc_list)
|
|
||||||
try:
|
try:
|
||||||
request_loop(wc_list)
|
request_loop(wc)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Terminated with Exception {e}")
|
print(f"Terminated with Exception {e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user