in main.py [0:0]
def main():
if "--debug" in sys.argv:
print("DEBUG MODE ENABLED. No emails will be sent.")
if "--debug_plugin" in sys.argv:
import logging
logger = logging.getLogger('gnupg')
logger.setLevel('DEBUG')
logger.addHandler(logging.StreamHandler())
logger.debug("Plugin debug enabled.")
start_time = time.time()
gpg_home = CFG["gpg_homedir"]
if not os.path.isdir(gpg_home):
print(f"Setting up GPG homedir in {gpg_home}")
os.mkdir(gpg_home)
projects = [x for x in os.listdir(CFG["dist_dir"]) if os.path.isdir(os.path.join(CFG["dist_dir"], x))]
# Weave in incubator podlings
projects.remove("incubator")
inc_dir = os.path.join(CFG["dist_dir"], "incubator")
podlings = [x for x in os.listdir(inc_dir) if os.path.isdir(os.path.join(inc_dir, x))]
projects.extend(podlings)
# Quick hack for only scanning certain dirs by adding the project name(s) to the command line
x_projects = []
for arg in sys.argv:
if arg in projects:
x_projects.append(arg)
if x_projects:
projects = x_projects
projects = [p for p in projects if f"-{p}" not in sys.argv] # to exclude POI: main.py -poi
while True:
for project in sorted(projects):
sys.stdout.write(f"- Scanning {project}...")
start_time_project = time.time()
keychain = load_keys(project, project in podlings)
errors = verify_files(project, keychain, project in podlings)
time_taken = int(time.time() - start_time_project)
if errors:
sys.stdout.write(f"BAD! (scan time: {time_taken} seconds)\n")
sys.stdout.flush()
alert_project(project, errors)
else:
sys.stdout.write(f"ALL GOOD! (scan time: {time_taken} seconds)\n")
sys.stdout.flush()
total_time_taken = int(time.time() - start_time)
print(f"Done scanning {len(projects)} projects in {total_time_taken} seconds.")
if "--forever" in sys.argv:
print(f"Sleeping for {INTERVAL} seconds.")
time.sleep(INTERVAL)
else:
break