add
This commit is contained in:
@@ -15,9 +15,8 @@ def older_than_a_day(fullpath):
|
||||
return time.time() - filetime > (gentooimgr.config.DAY_IN_SECONDS *
|
||||
gentooimgr.config.DAYS)
|
||||
|
||||
|
||||
|
||||
def find_iso(download_dir):
|
||||
LOG.info(f"Looking for iso in {download_dir}")
|
||||
name = None
|
||||
ext = None
|
||||
found = []
|
||||
@@ -34,9 +33,10 @@ def make_iso_from_dir(mydir):
|
||||
path to iso that was created or NoneType if mydir is not found
|
||||
"""
|
||||
if not os.path.exists(mydir):
|
||||
LOG.warn(f"\t:: dir not found {mydir}")
|
||||
return
|
||||
|
||||
print(f"\t:: Making ISO with dir of {mydir}")
|
||||
LOG.info(f"\t:: Making ISO with dir of {mydir}")
|
||||
path = os.path.join(mydir, "..", "cloudgen.iso")
|
||||
proc = Popen(["mkisofs",
|
||||
"--input-charset", "utf-8",
|
||||
@@ -52,15 +52,17 @@ def make_iso_from_dir(mydir):
|
||||
|
||||
return path
|
||||
|
||||
def portage_from_dir(d, filename=None):
|
||||
def portage_from_dir(download_dir, filename=None):
|
||||
"""Find portage file from directory. Will do a check in os.listdir() for portage*.tar.bz2.
|
||||
|
||||
If a filename is provided, this function either returns that filename assuming it exists in d,
|
||||
or return None. If filename is None, this looks through all entries for portage files and if
|
||||
only one exists, returns it, otherwise None.
|
||||
"""
|
||||
assert download_dir, f"empty {download_dir} for for portage"
|
||||
LOG.info(f"Looking for portage in {download_dir}")
|
||||
found = []
|
||||
for f in os.listdir(d):
|
||||
for f in os.listdir(download_dir):
|
||||
if filename is not None:
|
||||
if filename == f:
|
||||
found.append(f)
|
||||
@@ -70,7 +72,7 @@ def portage_from_dir(d, filename=None):
|
||||
if len(found) > 1:
|
||||
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")
|
||||
LOG.error(f"in {download_dir}\n")
|
||||
sys.exit(1)
|
||||
|
||||
return found[0] if found else None
|
||||
|
||||
Reference in New Issue
Block a user