Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MPSD HPC Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MPSD Computational Science
MPSD HPC Tools
Commits
fb0f72b7
Commit
fb0f72b7
authored
3 weeks ago
by
Henning Glawe
Browse files
Options
Downloads
Patches
Plain Diff
include terminating newline in format string
parent
6a197bdb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mpsd_hpc_tools/quota.py
+4
-6
4 additions, 6 deletions
src/mpsd_hpc_tools/quota.py
with
4 additions
and
6 deletions
src/mpsd_hpc_tools/quota.py
+
4
−
6
View file @
fb0f72b7
...
@@ -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__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment