returnResult.error(message=f"id:{fits_id} not found")
exceptExceptionase:
log.error(e)
returnResult.error(message=e.message)
defupdate_proc_status(self,**kwargs):
''' update the status of reduction
parameter kwargs:
id : [int],
status : [int]
return csst_dfs_common.models.Result
'''
fits_id=get_parameter(kwargs,"id")
status=get_parameter(kwargs,"status")
try:
existed=self.db.exists(
"select * from ifs_level1_data where id=?",
(fits_id,)
)
ifnotexisted:
log.warning('%s not found'%(fits_id,))
returnResult.error(message='%s not found'%(fits_id,))
self.db.execute(
'update ifs_level1_data set prc_status=?, prc_time=? where id=?',
(status,format_time_ms(time.time()),fits_id)
)
self.db.end()
returnResult.ok_data()
exceptExceptionase:
log.error(e)
returnResult.error(message=e.message)
defupdate_qc1_status(self,**kwargs):
''' update the status of QC1
parameter kwargs:
id : [int],
status : [int]
'''
fits_id=get_parameter(kwargs,"id")
status=get_parameter(kwargs,"status")
try:
existed=self.db.exists(
"select * from ifs_level1_data where id=?",
(fits_id,)
)
ifnotexisted:
log.warning('%s not found'%(fits_id,))
returnResult.error(message='%s not found'%(fits_id,))
self.db.execute(
'update ifs_level1_data set qc1_status=?, qc1_time=? where id=?',
(status,format_time_ms(time.time()),fits_id)
)
self.db.end()
returnResult.ok_data()
exceptExceptionase:
log.error(e)
returnResult.error(message=e.message)
defwrite(self,**kwargs):
''' insert a level1 record into database
parameter kwargs:
raw_id : [int]
data_type : [str]
cor_sci_id : [int]
prc_params : [str]
flat_id : [int]
dark_id : [int]
bias_id : [int]
lamp_id : [int]
arc_id : [int]
sky_id : [int]
filename : [str]
file_path : [str]
prc_status : [int]
prc_time : [str]
pipeline_id : [str]
return csst_dfs_common.models.Result
'''
try:
rec=Level1Record(
id=0,
raw_id=get_parameter(kwargs,"raw_id"),
data_type=get_parameter(kwargs,"data_type"),
cor_sci_id=get_parameter(kwargs,"cor_sci_id"),
prc_params=get_parameter(kwargs,"prc_params"),
flat_id=get_parameter(kwargs,"flat_id"),
dark_id=get_parameter(kwargs,"dark_id"),
bias_id=get_parameter(kwargs,"bias_id"),
lamp_id=get_parameter(kwargs,"lamp_id"),
arc_id=get_parameter(kwargs,"arc_id"),
sky_id=get_parameter(kwargs,"sky_id"),
filename=get_parameter(kwargs,"filename"),
file_path=get_parameter(kwargs,"file_path"),
prc_status=get_parameter(kwargs,"prc_status"),
prc_time=get_parameter(kwargs,"prc_time"),
pipeline_id=get_parameter(kwargs,"pipeline_id")
)
existed=self.db.exists(
"select * from ifs_level1_data where filename=?",
(rec.filename,)
)
ifexisted:
log.error(f'{rec.filename} has already been existed')
returnResult.error(message=f'{rec.filename} has already been existed')
self.db.execute(
'INSERT INTO ifs_level1_data (raw_id,data_type,cor_sci_id,prc_params,flat_id,dark_id,bias_id,lamp_id,arc_id,sky_id,filename,file_path,qc1_status,prc_status,create_time,pipeline_id) \
returnResult.error(message=f"id:{fits_id} not found")
exceptExceptionase:
log.error(e)
returnResult.error(message=str(e))
defupdate_proc_status(self,**kwargs):
''' update the status of reduction
parameter kwargs:
id : [int],
status : [int]
return csst_dfs_common.models.Result
'''
fits_id=get_parameter(kwargs,"id")
status=get_parameter(kwargs,"status")
try:
existed=self.db.exists(
"select * from msc_level1_data where id=?",
(fits_id,)
)
ifnotexisted:
log.warning('%s not found'%(fits_id,))
returnResult.error(message='%s not found'%(fits_id,))
self.db.execute(
'update msc_level1_data set prc_status=?, prc_time=? where id=?',
(status,format_time_ms(time.time()),fits_id)
)
self.db.end()
returnResult.ok_data()
exceptExceptionase:
log.error(e)
returnResult.error(message=str(e))
defupdate_qc1_status(self,**kwargs):
''' update the status of QC1
parameter kwargs:
id : [int],
status : [int]
'''
fits_id=get_parameter(kwargs,"id")
status=get_parameter(kwargs,"status")
try:
existed=self.db.exists(
"select * from msc_level1_data where id=?",
(fits_id,)
)
ifnotexisted:
log.warning('%s not found'%(fits_id,))
returnResult.error(message='%s not found'%(fits_id,))
self.db.execute(
'update msc_level1_data set qc1_status=?, qc1_time=? where id=?',
(status,format_time_ms(time.time()),fits_id)
)
self.db.end()
returnResult.ok_data()
exceptExceptionase:
log.error(e)
returnResult.error(message=str(e))
defwrite(self,**kwargs):
''' insert a level1 record into database
parameter kwargs:
raw_id : [int]
data_type : [str]
cor_sci_id : [int]
prc_params : [str]
flat_id : [int]
dark_id : [int]
bias_id : [int]
lamp_id : [int]
arc_id : [int]
sky_id : [int]
filename : [str]
file_path : [str]
prc_status : [int]
prc_time : [str]
pipeline_id : [str]
return csst_dfs_common.models.Result
'''
try:
rec=Level1Record(
id=0,
raw_id=get_parameter(kwargs,"raw_id"),
data_type=get_parameter(kwargs,"data_type"),
cor_sci_id=get_parameter(kwargs,"cor_sci_id"),
prc_params=get_parameter(kwargs,"prc_params"),
flat_id=get_parameter(kwargs,"flat_id"),
dark_id=get_parameter(kwargs,"dark_id"),
bias_id=get_parameter(kwargs,"bias_id"),
filename=get_parameter(kwargs,"filename"),
file_path=get_parameter(kwargs,"file_path"),
prc_status=get_parameter(kwargs,"prc_status"),
prc_time=get_parameter(kwargs,"prc_time"),
pipeline_id=get_parameter(kwargs,"pipeline_id")
)
existed=self.db.exists(
"select * from msc_level1_data where filename=?",
(rec.filename,)
)
ifexisted:
log.error(f'{rec.filename} has already been existed')
returnResult.error(message=f'{rec.filename} has already been existed')
self.db.execute(
'INSERT INTO msc_level1_data (raw_id,data_type,cor_sci_id,prc_params,flat_id,dark_id,bias_id,filename,file_path,qc1_status,prc_status,create_time,pipeline_id) \