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

get header

parent 6a55c623
...@@ -44,4 +44,10 @@ def read_file(file_path: str) -> BytesIO: ...@@ -44,4 +44,10 @@ def read_file(file_path: str) -> BytesIO:
iobytes_io.seek(0) iobytes_io.seek(0)
except OSError: except OSError:
raise AppError("Failed to read file.") raise AppError("Failed to read file.")
return iobytes_io return iobytes_io
\ No newline at end of file
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):
...@@ -33,4 +33,8 @@ class CommonTestCase(unittest.TestCase): ...@@ -33,4 +33,8 @@ 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