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-dfs
csst-dfs-client
Commits
aabe93dc
Commit
aabe93dc
authored
Jan 03, 2025
by
Wei Shoulin
Browse files
get header
parent
6a55c623
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_dfs_client/__init__.py
View file @
aabe93dc
...
...
@@ -44,4 +44,10 @@ def read_file(file_path: str) -> BytesIO:
iobytes_io
.
seek
(
0
)
except
OSError
:
raise
AppError
(
"Failed to read file."
)
return
iobytes_io
\ No newline at end of file
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
tests/test_common.py
View file @
aabe93dc
import
unittest
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
):
def
setUp
(
self
):
...
...
@@ -33,4 +33,8 @@ class CommonTestCase(unittest.TestCase):
assert
os
.
path
.
exists
(
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
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