Commit fc5ad88a authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

added utils for removing files/directory

parent 95f189eb
...@@ -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:
......
...@@ -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
......
...@@ -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,7 +11,8 @@ def remove_files(fmt=""): ...@@ -11,7 +11,8 @@ def remove_files(fmt=""):
def remove_dir(path=""): def remove_dir(path=""):
""" Remove the specified directory. """ """ Remove the specified directory. """
shutil.rmtree(path) if os.path.exists(path):
shutil.rmtree(path)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment