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
fc5ad88a
Commit
fc5ad88a
authored
Oct 31, 2022
by
BO ZHANG
🏀
Browse files
added utils for removing files/directory
parent
95f189eb
Changes
3
Show whitespace changes
Inline
Side-by-side
csst_common/data_manager.py
View file @
fc5ad88a
...
@@ -19,9 +19,10 @@ from typing import Union
...
@@ -19,9 +19,10 @@ from typing import Union
from
astropy.io
import
fits
from
astropy.io
import
fits
from
astropy.table
import
Table
from
astropy.table
import
Table
from
.dfs
import
gaia_query_from_dfs
from
.dfs
import
gaia_query_from_dfs
,
get_l1api
from
.params
import
CSST_PARAMS
as
CP
from
.params
import
CSST_PARAMS
as
CP
from
.params
import
DFS_CONF
from
.params
import
DFS_CONF
from
.utils
import
remove_files
,
remove_dir
class
CsstMsDataManager
:
class
CsstMsDataManager
:
...
@@ -182,6 +183,9 @@ class CsstMsDataManager:
...
@@ -182,6 +183,9 @@ class CsstMsDataManager:
# record hard code names in history
# record hard code names in history
self
.
hardcode_history
=
[]
self
.
hardcode_history
=
[]
# DFS APIs
# self.l1api = Level1DataApi()
@
property
@
property
def
dfs_node
(
self
):
def
dfs_node
(
self
):
return
self
.
_dfs_node
return
self
.
_dfs_node
...
@@ -488,6 +492,19 @@ class CsstMsDataManager:
...
@@ -488,6 +492,19 @@ class CsstMsDataManager:
lines
+=
f
"CSST_DFS_GATEWAY = "
+
os
.
getenv
(
"CSST_DFS_GATEWAY"
)
+
"
\n
"
lines
+=
f
"CSST_DFS_GATEWAY = "
+
os
.
getenv
(
"CSST_DFS_GATEWAY"
)
+
"
\n
"
return
lines
return
lines
@
staticmethod
def
remove_files
(
fmt
=
"./*_post.fits"
):
remove_files
(
fmt
=
fmt
)
@
staticmethod
def
remove_dir
(
path
):
remove_dir
(
path
)
def
dfs_push_l1
(
self
):
l1api
=
get_l1api
()
l1api
.
write
()
return
class
CsstMbiDataManager
:
class
CsstMbiDataManager
:
...
...
csst_common/dfs.py
View file @
fc5ad88a
...
@@ -15,7 +15,6 @@ def gaia_query_from_dfs(ra=180, dec=0, radius=2, min_mag=0, max_mag=30, obstime=
...
@@ -15,7 +15,6 @@ def gaia_query_from_dfs(ra=180, dec=0, radius=2, min_mag=0, max_mag=30, obstime=
return
tbl
return
tbl
# TODO: the l1api is not completed
def
get_l1api
(
node
=
"pm"
):
def
get_l1api
(
node
=
"pm"
):
""" get DFS L1 API
""" get DFS L1 API
...
...
csst_common/utils/_io.py
View file @
fc5ad88a
...
@@ -3,7 +3,7 @@ import os
...
@@ -3,7 +3,7 @@ import os
import
shutil
import
shutil
def
remove_files
(
fmt
=
""
):
def
remove_files
(
fmt
=
"
*post.fits
"
):
""" Remove files matching the specified format. """
""" Remove files matching the specified format. """
for
fp
in
glob
.
glob
(
fmt
):
for
fp
in
glob
.
glob
(
fmt
):
os
.
remove
(
fp
)
os
.
remove
(
fp
)
...
@@ -11,6 +11,7 @@ def remove_files(fmt=""):
...
@@ -11,6 +11,7 @@ def remove_files(fmt=""):
def
remove_dir
(
path
=
""
):
def
remove_dir
(
path
=
""
):
""" Remove the specified directory. """
""" Remove the specified directory. """
if
os
.
path
.
exists
(
path
):
shutil
.
rmtree
(
path
)
shutil
.
rmtree
(
path
)
...
...
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