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
from astropy.io import fits
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 DFS_CONF
from .utils import remove_files, remove_dir
class CsstMsDataManager:
......@@ -182,6 +183,9 @@ class CsstMsDataManager:
# record hard code names in history
self.hardcode_history = []
# DFS APIs
# self.l1api = Level1DataApi()
@property
def dfs_node(self):
return self._dfs_node
......@@ -488,6 +492,19 @@ class CsstMsDataManager:
lines += f"CSST_DFS_GATEWAY = " + os.getenv("CSST_DFS_GATEWAY") + "\n"
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:
......
......@@ -15,7 +15,6 @@ def gaia_query_from_dfs(ra=180, dec=0, radius=2, min_mag=0, max_mag=30, obstime=
return tbl
# TODO: the l1api is not completed
def get_l1api(node="pm"):
""" get DFS L1 API
......
......@@ -3,7 +3,7 @@ import os
import shutil
def remove_files(fmt=""):
def remove_files(fmt="*post.fits"):
""" Remove files matching the specified format. """
for fp in glob.glob(fmt):
os.remove(fp)
......@@ -11,6 +11,7 @@ def remove_files(fmt=""):
def remove_dir(path=""):
""" Remove the specified directory. """
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