def note_file_created(self, file_obj):
"""Tell M&C about a new Librarian file. M&C file records can also have null
obsids, so we don't need to do anything special for maintenance files.
"""
try:
self.mc_session.add_lib_file(file_obj.name, file_obj.obsid,
file_obj.create_time_astropy,
file_obj.size / 1024**3)
except InvalidRequestError as e:
# This could happen if the file's obsid were not registered in the
# M&C database. Which shouldn't happen, but ...
self.error(SEVERE, 'couldn\'t register file %s (obsid %s) with M&C: %s',
file_obj.name, file_obj.obsid, e)
try:
self.mc_session.commit()
except SQLAlchemyError as e:
self.mc_session.rollback()
self.error(SEVERE, 'could not commit file creation note to the M&C system: %s', e)
评论列表
文章目录