Commit aabe93dc authored by Wei Shoulin's avatar Wei Shoulin
Browse files

get header

parent 6a55c623
...@@ -45,3 +45,9 @@ def read_file(file_path: str) -> BytesIO: ...@@ -45,3 +45,9 @@ def read_file(file_path: str) -> BytesIO:
except OSError: except OSError:
raise AppError("Failed to read file.") raise AppError("Failed to read file.")
return iobytes_io return iobytes_io
def get_free_header(file_path: str) -> dict:
result = request.get(f"/api/common/header?file_path={file_path}")
if result.success:
return result.data
raise AppError("Failed to get free header. Reason: " + result.message)
\ No newline at end of file
import unittest import unittest
import os import os
from csst_dfs_client import download_file, read_file from csst_dfs_client import download_file, read_file, get_free_header
class CommonTestCase(unittest.TestCase): class CommonTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -34,3 +34,7 @@ class CommonTestCase(unittest.TestCase): ...@@ -34,3 +34,7 @@ class CommonTestCase(unittest.TestCase):
assert os.path.exists(tmp_file_path) assert os.path.exists(tmp_file_path)
os.remove(tmp_file_path) os.remove(tmp_file_path)
def test_get_free_header(self):
header_items = get_free_header(file_path= "L0/MSC/routine/SCI/10109100157991/CSST_MSC_MS_SCI_20240609181116_20240609181347_10109100157991_27_L0_V01.fits")
print(header_items)
\ No newline at end of file
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