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
b1bd3f1d
Commit
b1bd3f1d
authored
1 month ago
by
Henning Glawe
Browse files
Options
Downloads
Patches
Plain Diff
catch errors of system commands
parent
4f74bd2d
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
+14
-8
14 additions, 8 deletions
src/mpsd_hpc_tools/quota.py
with
14 additions
and
8 deletions
src/mpsd_hpc_tools/quota.py
+
14
−
8
View file @
b1bd3f1d
...
@@ -45,7 +45,7 @@ def get_ceph_attribute(path: str, attribute: str) -> int:
...
@@ -45,7 +45,7 @@ def get_ceph_attribute(path: str, attribute: str) -> int:
return
int
(
output
)
return
int
(
output
)
def
df_ceph
(
path
_obj
:
pathlib
.
Path
)
->
Tuple
[
int
,
int
,
int
]:
def
df_ceph
(
path
:
pathlib
.
Path
)
->
Tuple
[
int
,
int
,
int
]:
"""
"""
Given a path (such as
'
/scratch/fangohr
'
) return the number of bytes
Given a path (such as
'
/scratch/fangohr
'
) return the number of bytes
(size, used, available).
(size, used, available).
...
@@ -57,14 +57,17 @@ def df_ceph(path_obj: pathlib.Path) -> Tuple[int, int, int]:
...
@@ -57,14 +57,17 @@ def df_ceph(path_obj: pathlib.Path) -> Tuple[int, int, int]:
>>>
df_ceph
(
"
/scratch/fangohr
"
)
>>>
df_ceph
(
"
/scratch/fangohr
"
)
(
25000000000000
,
1780686359
,
24998219313641
)
(
25000000000000
,
1780686359
,
24998219313641
)
"""
"""
path
=
str
(
path_obj
)
try
:
used
=
get_ceph_attribute
(
path
,
"
ceph.dir.rbytes
"
)
used
=
get_ceph_attribute
(
path
,
"
ceph.dir.rbytes
"
)
size
=
get_ceph_attribute
(
path
,
"
ceph.quota.max_bytes
"
)
size
=
get_ceph_attribute
(
path
,
"
ceph.quota.max_bytes
"
)
avail
=
size
-
used
except
:
used
,
size
,
avail
=
None
,
None
,
None
else
:
avail
=
size
-
used
return
size
,
used
,
avail
return
size
,
used
,
avail
def
df_mountpoint
(
path
_obj
:
pathlib
.
Path
)
->
Tuple
[
int
,
int
,
int
]:
def
df_mountpoint
(
path
:
pathlib
.
Path
)
->
Tuple
[
int
,
int
,
int
]:
"""
"""
Given a path (such as
'
/home/fangohr
'
) return the number of bytes
Given a path (such as
'
/home/fangohr
'
) return the number of bytes
(size, used, available).
(size, used, available).
...
@@ -76,9 +79,12 @@ def df_mountpoint(path_obj: pathlib.Path) -> Tuple[int, int, int]:
...
@@ -76,9 +79,12 @@ def df_mountpoint(path_obj: pathlib.Path) -> Tuple[int, int, int]:
>>>
df
(
"
/home/fangohr
"
)
>>>
df
(
"
/home/fangohr
"
)
(
25000000000000
,
1780686359
,
24998219313641
)
(
25000000000000
,
1780686359
,
24998219313641
)
"""
"""
path
=
str
(
path_obj
)
size
,
used
,
avail
=
None
,
None
,
None
cmd
=
[
"
df
"
,
"
--block-size=1
"
,
path
]
cmd
=
[
"
df
"
,
"
--block-size=1
"
,
path
]
df_run
=
subprocess
.
run
(
cmd
,
check
=
True
,
stdout
=
subprocess
.
PIPE
,
text
=
True
)
try
:
df_run
=
subprocess
.
run
(
cmd
,
check
=
True
,
stdout
=
subprocess
.
PIPE
,
text
=
True
)
except
:
return
None
,
None
,
None
for
line
in
df_run
.
stdout
.
splitlines
():
for
line
in
df_run
.
stdout
.
splitlines
():
l
=
line
.
split
()
l
=
line
.
split
()
if
(
l
[
0
]
==
"
Filesystem
"
):
if
(
l
[
0
]
==
"
Filesystem
"
):
...
...
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