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-api
Commits
b67361fb
Commit
b67361fb
authored
Mar 24, 2021
by
Wei Shoulin
Browse files
yield bug
parent
f1c8509a
Changes
5
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api/ifs/fits.py
View file @
b67361fb
...
...
@@ -71,5 +71,5 @@ class FitsApi(object):
parameter kwargs:
file_path = [str]
'''
yield
self
.
stub
.
write
(
**
kwargs
)
return
self
.
stub
.
write
(
**
kwargs
)
csst_dfs_api/ifs/reffits.py
View file @
b67361fb
...
...
@@ -70,5 +70,5 @@ class RefFitsApi(object):
parameter kwargs:
file_path = [str]
'''
yield
self
.
stub
.
write
(
**
kwargs
)
return
self
.
stub
.
write
(
**
kwargs
)
csst_dfs_api/ifs/result0.py
View file @
b67361fb
...
...
@@ -52,5 +52,5 @@ class Result0Api(object):
file_path = [str],
proc_type = [str]
'''
yield
self
.
stub
.
write
(
**
kwargs
)
return
self
.
stub
.
write
(
**
kwargs
)
csst_dfs_api/ifs/result1.py
View file @
b67361fb
...
...
@@ -51,5 +51,5 @@ class Result1Api(object):
proc_type = [str],
result0_ids = [list]
'''
yield
self
.
stub
.
write
(
**
kwargs
)
return
self
.
stub
.
write
(
**
kwargs
)
tests/test_ifs_refs.py
View file @
b67361fb
...
...
@@ -10,34 +10,34 @@ class IFSFitsTestCase(unittest.TestCase):
self
.
api
=
RefFitsApi
()
def
test_find
(
self
):
recs
=
self
.
api
.
find
(
exp_time
=
(
'2021-03-
19 13:42:22
'
,
'2021-03-
19 15:28:00
'
),
ref_type
=
RefFitsApi
.
REF_FITS_FLAT
)
recs
=
self
.
api
.
find
(
exp_time
=
(
'2021-03-
24 10:14:56
'
,
'2021-03-
24 10:15:56
'
),
ref_type
=
RefFitsApi
.
REF_FITS_FLAT
)
print
(
'find:'
,
recs
)
assert
len
(
recs
)
>
1
recs
=
self
.
api
.
find
()
print
(
'='
*
80
)
print
(
'find:'
,
recs
)
assert
len
(
recs
)
>
1
def
test_read
(
self
):
recs
=
self
.
api
.
find
(
file_name
=
'CCD2_Flat_img.fits'
)
print
(
"The full path: "
,
os
.
path
.
join
(
self
.
api
.
file_prefix
,
recs
[
0
][
'file_path'
]))
file_segments
=
self
.
api
.
read
(
file_path
=
recs
[
0
][
'file_path'
])
file_bytes
=
b
''
.
join
(
file_segments
)
hdul
=
fits
.
HDUList
.
fromstring
(
file_bytes
)
print
(
hdul
.
info
())
hdr
=
hdul
[
0
].
header
print
(
repr
(
hdr
))
def
test_update_status
(
self
):
recs
=
self
.
api
.
find
(
file_name
=
'CCD2_Flat_img.fits'
)
self
.
api
.
update_status
(
fits_id
=
recs
[
0
][
'id'
],
status
=
1
)
rec
=
self
.
api
.
get
(
fits_id
=
recs
[
0
][
'id'
])
assert
rec
[
'status'
]
==
1
def
test_write
(
self
):
recs
=
self
.
api
.
write
(
file_path
=
'/opt/temp/csst_ifs/CCD3_Flat_img.fits'
)
recs
=
self
.
api
.
find
(
file_name
=
'CCD3_Flat_img.fits'
)
rec
=
self
.
api
.
get
(
fits_id
=
recs
[
0
][
'id'
])
print
(
rec
)
#
assert len(recs) > 1
#
recs = self.api.find()
#
print('=' * 80)
#
print('find:', recs)
#
assert len(recs) > 1
#
def test_read(self):
#
recs = self.api.find(file_name='CCD2_Flat_img.fits')
#
print("The full path: ", os.path.join(self.api.file_prefix, recs[0]['file_path']))
#
file_segments = self.api.read(file_path=recs[0]['file_path'])
#
file_bytes = b''.join(file_segments)
#
hdul = fits.HDUList.fromstring(file_bytes)
#
print(hdul.info())
#
hdr = hdul[0].header
#
print(repr(hdr))
#
def test_update_status(self):
#
recs = self.api.find(file_name='CCD2_Flat_img.fits')
#
self.api.update_status(fits_id=recs[0]['id'],status=1)
#
rec = self.api.get(fits_id=recs[0]['id'])
#
assert rec['status'] == 1
#
def test_write(self):
#
recs = self.api.write(file_path='/opt/temp/csst_ifs/CCD3_Flat_img.fits')
#
recs = self.api.find(file_name='CCD3_Flat_img.fits')
#
rec = self.api.get(fits_id=recs[0]['id'])
#
print(rec)
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