fixing standalone run, disabling unnecessary logs from urllib3,

This commit is contained in:
iRaven 2022-09-28 03:38:29 -05:00
parent e4f0d705c6
commit cdb303825d
2 changed files with 17 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
CCTVCrawl*
devscrape*
OLD_devscrape*
*.log
__pycache__

23
main.py
View File

@ -12,15 +12,15 @@ import threading
# author: iRaven (https://iravenhome.net)
# Started 9/6/22.
#version = "2021.9.8"
#version = "2022.9.28"
# Configure logging
logging.basicConfig(filename="TransArchive.log",
format='%(asctime)s %(message)s',
format='%(asctime)s %(levelname)s %(message)s',
filemode='a')
log = logging.getLogger()
log.setLevel(logging.DEBUG)
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
#define local vars
@ -35,7 +35,7 @@ csvfile = (f"TransArchive_{curdate}.csv") # mainly for debugging but to show sta
csvfields = ['time','camera_id', 'status'] # ^
# 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)
vftxt = open("valid_feed_list.txt", "r")
vfdata = vftxt.read()
@ -60,7 +60,7 @@ def initFolder(startmode):
log.warning("archive folder for todays date doesn't exist (expected LOL), creating it")
os.makedirs(f"archive/{curdate}")
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:
csvwrite = csv.writer(listfile)
csvwrite.writerow(csvfields)
@ -125,6 +125,7 @@ def MainMenu():
# Arguments
for arg in arglist:
# print(arglist)
if arg in ("-archive"):
# print("Archive was passed") # debugging
initFolder("script")
@ -132,7 +133,15 @@ for arg in arglist:
elif arg in ("-testarg"): # debugging, left to test arguments
print("test arg was passed")
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("unrecognized args were passed!")
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