Skip to content
Snippets Groups Projects
Commit fb0f72b7 authored by Henning Glawe's avatar Henning Glawe
Browse files

include terminating newline in format string

parent 6a197bdb
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str: ...@@ -116,7 +116,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str:
/scratch/fangohr 1.78 GB 25.00 TB 0.00712% /scratch/fangohr 1.78 GB 25.00 TB 0.00712%
""" """
format_string = "{:20} {:>14} {:>14} {:>14.4}%" format_string = "{:20} {:>14} {:>14} {:>14.4}%\n"
out = format_string.format("location", "used", "avail", "use") out = format_string.format("location", "used", "avail", "use")
if homedir: if homedir:
...@@ -128,7 +128,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str: ...@@ -128,7 +128,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str:
used, avail = map(str, [used_bytes, avail_bytes]) used, avail = map(str, [used_bytes, avail_bytes])
else: else:
used, avail = map(humanise_size, [used_bytes, avail_bytes]) used, avail = map(humanise_size, [used_bytes, avail_bytes])
out += "\n" + format_string.format(str(homedir), used, avail, rel) out += format_string.format(str(homedir), used, avail, rel)
if scratchdir: if scratchdir:
scratchdir = pathlib.Path(scratchdir) scratchdir = pathlib.Path(scratchdir)
...@@ -138,7 +138,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str: ...@@ -138,7 +138,7 @@ def compose_quota_report(homedir=None, scratchdir=None, bytes=False) -> str:
used, avail = map(str, [used_bytes, avail_bytes]) used, avail = map(str, [used_bytes, avail_bytes])
else: else:
used, avail = map(humanise_size, [used_bytes, avail_bytes]) used, avail = map(humanise_size, [used_bytes, avail_bytes])
out += "\n" + format_string.format(str(scratchdir), used, avail, rel) out += format_string.format(str(scratchdir), used, avail, rel)
return out return out
...@@ -210,8 +210,6 @@ def main(argv=None): ...@@ -210,8 +210,6 @@ def main(argv=None):
sys.stderr.write(f"Home directory {str(homedir)} does not exist ({user=}).\n") sys.stderr.write(f"Home directory {str(homedir)} does not exist ({user=}).\n")
sys.exit(1) sys.exit(1)
# do the work
scratchdir = pathlib.Path("/scratch") / user scratchdir = pathlib.Path("/scratch") / user
# only proceed if user has a directory on /scratch # only proceed if user has a directory on /scratch
if not scratchdir.is_dir(): if not scratchdir.is_dir():
...@@ -220,7 +218,7 @@ def main(argv=None): ...@@ -220,7 +218,7 @@ def main(argv=None):
output = compose_quota_report( output = compose_quota_report(
homedir=homedir, bytes=args.bytes, scratchdir=scratchdir homedir=homedir, bytes=args.bytes, scratchdir=scratchdir
) )
print(output) sys.stdout.write(output)
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment