Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_common
Commits
943e120c
Commit
943e120c
authored
Jul 09, 2024
by
BO ZHANG
🏀
Browse files
print directory tree if rm -rf failed
parent
26cd1b2f
Pipeline
#6109
passed with stage
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
csst_common/pipeline.py
View file @
943e120c
...
...
@@ -10,6 +10,7 @@ Modified-History:
2023-12-10, Bo Zhang, update Pipeline
2023-12-15, Bo Zhang, add module header
"""
import
json
import
subprocess
import
os
...
...
@@ -29,6 +30,16 @@ from .logger import get_logger
from
.status
import
CsstStatus
,
CsstResult
def
print_directory_tree
(
directory
=
"."
):
for
root
,
dirs
,
files
in
os
.
walk
(
directory
):
level
=
root
.
replace
(
directory
,
""
).
count
(
os
.
sep
)
indent
=
" "
*
4
*
(
level
)
print
(
f
"
{
indent
}{
os
.
path
.
basename
(
root
)
}
/"
)
subindent
=
" "
*
4
*
(
level
+
1
)
for
file
in
files
:
print
(
f
"
{
subindent
}{
file
}
"
)
class
Pipeline
:
"""
CSST pipeline configuration class.
...
...
@@ -166,9 +177,13 @@ class Pipeline:
def
clean_directory
(
d
):
"""Clean a directory."""
print
(
f
"Clean output directory '
{
d
}
'..."
)
r
=
subprocess
.
run
(
f
"rm -rf
{
d
}
/*"
,
shell
=
True
,
capture_output
=
True
)
print
(
"> "
,
r
)
r
.
check_returncode
()
try
:
r
=
subprocess
.
run
(
f
"rm -rf
{
d
}
/*"
,
shell
=
True
,
capture_output
=
True
)
print
(
"> "
,
r
)
r
.
check_returncode
()
except
:
print
(
"Failed to clean output directory!"
)
print_directory_tree
(
d
)
def
now
(
self
):
"""Return ISOT format datetime using `astropy`."""
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment