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-local
Commits
1abe728d
Commit
1abe728d
authored
Apr 06, 2021
by
Wei Shoulin
Browse files
fill file_path
parent
c66fb6d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/ifs/fits.py
View file @
1abe728d
...
...
@@ -66,9 +66,10 @@ class FitsApi(object):
if
file_name
:
sql
=
[
"select * from ifs_rawfits where filename='"
+
file_name
+
"'"
]
_
,
r
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
return
r
_
,
recs
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
for
r
in
recs
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
recs
def
get
(
self
,
**
kwargs
):
'''
...
...
@@ -80,6 +81,8 @@ class FitsApi(object):
fits_id
=
get_parameter
(
kwargs
,
"fits_id"
,
-
1
)
r
=
self
.
db
.
select_one
(
"select * from ifs_rawfits where id=?"
,
(
fits_id
,))
if
r
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
r
def
read
(
self
,
**
kwargs
):
...
...
csst_dfs_api_local/ifs/reffits.py
View file @
1abe728d
...
...
@@ -67,9 +67,11 @@ class RefFitsApi(object):
if
file_name
:
sql
=
[
"select * from ifs_ref_fits where filename='"
+
file_name
+
"'"
]
sql
.
append
(
" order by exp_time desc"
)
_
,
r
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
_
,
r
ecs
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
return
r
for
r
in
recs
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
recs
def
get
(
self
,
**
kwargs
):
'''query database, return a record as dict
...
...
@@ -82,6 +84,8 @@ class RefFitsApi(object):
fits_id
=
get_parameter
(
kwargs
,
"fits_id"
,
-
1
)
r
=
self
.
db
.
select_one
(
"select * from ifs_ref_fits where id=?"
,
(
fits_id
,))
if
r
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
r
def
read
(
self
,
**
kwargs
):
...
...
csst_dfs_api_local/ifs/result0.py
View file @
1abe728d
...
...
@@ -47,9 +47,11 @@ class Result0Api(object):
if
file_name
:
sql
=
[
"select * from ifs_result_0 where filename='"
+
file_name
+
"'"
]
_
,
r
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
_
,
r
ecs
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
return
r
for
r
in
recs
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
recs
def
get
(
self
,
**
kwargs
):
''' query database, return a record as dict
...
...
@@ -62,6 +64,8 @@ class Result0Api(object):
fits_id
=
get_parameter
(
kwargs
,
"fits_id"
,
-
1
)
r
=
self
.
db
.
select_one
(
"select * from ifs_result_0 where id=?"
,
(
fits_id
,))
if
r
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
r
def
read
(
self
,
**
kwargs
):
...
...
csst_dfs_api_local/ifs/result1.py
View file @
1abe728d
...
...
@@ -39,9 +39,11 @@ class Result1Api(object):
if
file_name
:
sql
=
[
"select * from ifs_result_1 where filename='"
+
file_name
+
"'"
]
_
,
r
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
_
,
r
ecs
=
self
.
db
.
select_many
(
""
.
join
(
sql
))
return
r
for
r
in
recs
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
recs
def
get
(
self
,
**
kwargs
):
'''
...
...
@@ -56,7 +58,8 @@ class Result1Api(object):
_
,
result0s
=
self
.
db
.
select_many
(
"select result0_id, create_time from ifs_result_0_1 where result1_id=?"
,
(
fits_id
,))
if
r
:
r
[
'file_path'
]
=
os
.
path
.
join
(
self
.
root_dir
,
r
[
'file_path'
])
return
r
,
result0s
def
read
(
self
,
**
kwargs
):
...
...
tests/test_ifs_fits.py
View file @
1abe728d
...
...
@@ -9,6 +9,13 @@ class IFSFitsTestCase(unittest.TestCase):
def
setUp
(
self
):
self
.
api
=
FitsApi
()
def
test_get
(
self
):
r
=
self
.
api
.
get
(
fits_id
=
1111
)
print
(
'get:'
,
r
)
r
=
self
.
api
.
get
(
fits_id
=
1
)
print
(
'get:'
,
r
)
def
test_find
(
self
):
recs
=
self
.
api
.
find
(
file_name
=
'CCD1_ObsTime_300_ObsNum_7.fits'
)
print
(
'find:'
,
recs
)
...
...
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