fixing standalone run, disabling unnecessary logs from urllib3,
This commit is contained in:
parent
e4f0d705c6
commit
cdb303825d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
CCTVCrawl*
|
CCTVCrawl*
|
||||||
devscrape*
|
devscrape*
|
||||||
|
OLD_devscrape*
|
||||||
*.log
|
*.log
|
||||||
__pycache__
|
__pycache__
|
||||||
|
23
main.py
23
main.py
@ -12,15 +12,15 @@ import threading
|
|||||||
# author: iRaven (https://iravenhome.net)
|
# author: iRaven (https://iravenhome.net)
|
||||||
# Started 9/6/22.
|
# Started 9/6/22.
|
||||||
|
|
||||||
#version = "2021.9.8"
|
#version = "2022.9.28"
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
logging.basicConfig(filename="TransArchive.log",
|
logging.basicConfig(filename="TransArchive.log",
|
||||||
format='%(asctime)s %(message)s',
|
format='%(asctime)s %(levelname)s %(message)s',
|
||||||
filemode='a')
|
filemode='a')
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
logging.getLogger("requests").setLevel(logging.WARNING)
|
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||||
|
|
||||||
#define local vars
|
#define local vars
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ csvfile = (f"TransArchive_{curdate}.csv") # mainly for debugging but to show sta
|
|||||||
csvfields = ['time','camera_id', 'status'] # ^
|
csvfields = ['time','camera_id', 'status'] # ^
|
||||||
|
|
||||||
# very important var: where we get everything
|
# very important var: where we get everything
|
||||||
cctvurl = (f'https://www.houstontranstar.org/snapshots/cctv/') # Last updated Sep-2022
|
cctvurl = (f'https://www.houstontranstar.org/snapshots/cctv/') # Last updated Sep-6-2022
|
||||||
# very important var: list of valid camera feeds generated by devs (likely included and updated in repo)
|
# very important var: list of valid camera feeds generated by devs (likely included and updated in repo)
|
||||||
vftxt = open("valid_feed_list.txt", "r")
|
vftxt = open("valid_feed_list.txt", "r")
|
||||||
vfdata = vftxt.read()
|
vfdata = vftxt.read()
|
||||||
@ -60,7 +60,7 @@ def initFolder(startmode):
|
|||||||
log.warning("archive folder for todays date doesn't exist (expected LOL), creating it")
|
log.warning("archive folder for todays date doesn't exist (expected LOL), creating it")
|
||||||
os.makedirs(f"archive/{curdate}")
|
os.makedirs(f"archive/{curdate}")
|
||||||
elif not os.path.exists(f"TransstarArchive_{curdate}.csv"):
|
elif not os.path.exists(f"TransstarArchive_{curdate}.csv"):
|
||||||
log.error("csv file doesn't exist. creating it for today")
|
log.warning("csv file doesn't exist. creating it for today")
|
||||||
with open(csvfile, 'a') as listfile:
|
with open(csvfile, 'a') as listfile:
|
||||||
csvwrite = csv.writer(listfile)
|
csvwrite = csv.writer(listfile)
|
||||||
csvwrite.writerow(csvfields)
|
csvwrite.writerow(csvfields)
|
||||||
@ -125,6 +125,7 @@ def MainMenu():
|
|||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
for arg in arglist:
|
for arg in arglist:
|
||||||
|
# print(arglist)
|
||||||
if arg in ("-archive"):
|
if arg in ("-archive"):
|
||||||
# print("Archive was passed") # debugging
|
# print("Archive was passed") # debugging
|
||||||
initFolder("script")
|
initFolder("script")
|
||||||
@ -132,7 +133,15 @@ for arg in arglist:
|
|||||||
elif arg in ("-testarg"): # debugging, left to test arguments
|
elif arg in ("-testarg"): # debugging, left to test arguments
|
||||||
print("test arg was passed")
|
print("test arg was passed")
|
||||||
log.debug("Test arg was passed -- not running")
|
log.debug("Test arg was passed -- not running")
|
||||||
else: # no arguments are passed, just running the file from a folder (which is oki)
|
else: # unrecognized arguments are passed (which is oki)
|
||||||
# log.debug("no args were passed!")
|
# log.debug("no args were passed!")
|
||||||
|
# log.debug("unrecognized args were passed!")
|
||||||
initFolder("normal")
|
initFolder("normal")
|
||||||
MainMenu()
|
MainMenu()
|
||||||
|
|
||||||
|
# noticed an issue where this doesn't run standalone anymore. maybe this will fix it. idk
|
||||||
|
if len(arglist) == 0:
|
||||||
|
# log.debug("no args were passed!")
|
||||||
|
initFolder("noarg")
|
||||||
|
MainMenu()
|
||||||
|
# 09/28/22- ok this will semi work for now. if any arg other than the ones defined above are passed it'll ignore them and run like none were passed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user