Commit fe8389ac authored by Dennis Baurichter's avatar Dennis Baurichter

Fixup mkprints

 * Fixes todo: resolve folder paths
 * Fix exception handling from handle_folders() methods
 * Print output file name at the end
 * Remove temporary files
parent 1bd79268
......@@ -70,9 +70,21 @@ try:
folder=folderreg.folders[arg]
if not folder in folders:
folders.append(folder)
# todo: resolve folder paths
elif os.path.isdir(arg):
realpath=os.path.realpath(arg)
split=os.path.basename(realpath).split(" - ")
if len(split) != 3:
raise CLEx("Folder ID not found in path: %s"%arg)
fid=split[2]
folder=folderreg.folders[fid]
if folder.path != realpath:
raise CLEx(("Folder mismatch: Found ID {id} for {arg}\n"
"Folder registry reports other path {path}"
).format(id=fid,arg=arg,path=folder.path))
if not folder in folders:
folders.append(folder)
else:
raise CLEx("folder not found / stray argument: %s"%arg)
raise CLEx("Folder not found / stray argument: %s"%arg)
elif s=="--output":
outfile=arg
s=None
......@@ -108,9 +120,11 @@ try:
os.chdir(subtmpdir)
try:
res=printer.handle_folders(folders)
except:
except Exception:
sys.stderr.write(
"\x1b[31;1mError\x1b[30;0m: An exception occured while handling %s:\n"
%flag)
raise
continue
finally:
os.chdir(tmpdir)
......@@ -132,8 +146,9 @@ try:
" ".join([shlex.quote(v) for v in pieces]),
shlex.quote(outfile)))
print("\nOutput written to \x1b[34;1m%s\x1b[30;0m"%outfile)
finally:
#shutil.rmtree(tmpdir)
os.chdir(cwd)
shutil.rmtree(tmpdir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment