added logging

This commit is contained in:
embed@git.macaw.me
2023-12-21 19:42:13 +00:00
parent f7303dce15
commit 06cffbdbd7
14 changed files with 321 additions and 51 deletions

View File

@@ -6,12 +6,15 @@ import json
from subprocess import Popen, PIPE
import gentooimgr.config
from gentooimgr import LOG
def older_than_a_day(fullpath):
if not os.path.exists(fullpath):
return True # Don't fail on missing files
filetime = os.path.getmtime(fullpath)
return time.time() - filetime > gentooimgr.config.DAY_IN_SECONDS
return time.time() - filetime > (gentooimgr.config.DAY_IN_SECONDS *
gentooimgr.config.DAYS)
def find_iso(download_dir):
@@ -65,9 +68,9 @@ def portage_from_dir(d, filename=None):
found.append(f)
if len(found) > 1:
sys.stderr.write("\tEE: More than one portage file exists, please specify the exact portage file with --portage [file] or remove all others\n")
sys.stderr.write(''.join([f"\t{f}\n" for f in found]))
sys.stderr.write(f"in {d}\n")
LOG.error("\tEE: More than one portage file exists, please specify the exact portage file with --portage [file] or remove all others\n")
LOG.error(''.join([f"\t{f}\n" for f in found]))
LOG.error(f"in {d}\n")
sys.exit(1)
return found[0] if found else None
@@ -89,9 +92,9 @@ def stage3_from_dir(d, filename=None):
found.append(f)
if len(found) > 1:
sys.stderr.write("More than one stage3 file exists, please specify the exact stage3 file or remove all others\n")
sys.stderr.write(''.join([f"\t{f}\n" for f in found]))
sys.stderr.write(f"in {d}\n")
LOG.error("More than one stage3 file exists, please specify the exact stage3 file or remove all others\n")
LOG.error(''.join([f"\t{f}\n" for f in found]))
LOG.error(f"in {d}\n")
return None
return found[0] if found else None