コード例 #1
0
 def __init__(self, pe_id=None):
     if pe_id is None:
         parser = argparse.ArgumentParser(
             description='A user defined script.')
         parser.add_argument('--idx',
                             nargs='?',
                             action='store',
                             help='Id of related pipeline element.')
         args = parser.parse_args()
     lostconfig = LOSTConfig()
     dbm = access.DBMan(lostconfig)
     db_fs = dbm.get_fs(name='lost_data')
     self.file_man = FileMan(fs_db=db_fs)
     self._dbm = dbm  #type: lost.db.access.DBMan
     if pe_id is None:
         pe = dbm.get_pipe_element(int(args.idx))
     else:
         pe = dbm.get_pipe_element(pe_id)
     super().__init__(pe, dbm)
     logfile_path = self.file_man.get_pipe_log_path(self._pipe.idx)
     self._log_stream = self.file_man.fs.open(logfile_path, 'a')
     self._logger = log.get_stream_logger(os.path.basename(pe.script.path),
                                          self._log_stream)
     if self.pipe_info.logfile_path is None or not self.pipe_info.logfile_path:
         self.pipe_info.logfile_path = self.get_rel_path(logfile_path)
     self._inp = inout.Input(self)
     self._outp = inout.ScriptOutput(self)
     self.rejected_execution = False
     # If pe_id is None we have a normal script
     # If pe_id is not None a JupyterNotebook uses this script
     if pe_id is None:
         return self._run()
コード例 #2
0
 def __init__(self, pe_id=None):
     if pe_id is None:
         parser = argparse.ArgumentParser(description='A user defined script.')
         parser.add_argument('--idx', nargs='?', action='store',
                             help='Id of related pipeline element.')
         args = parser.parse_args()
     lostconfig = LOSTConfig()
     self.file_man = FileMan(lostconfig)
     dbm = access.DBMan(lostconfig)
     self._dbm = dbm #type: lost.db.access.DBMan
     if pe_id is None:
         pe = dbm.get_pipe_element(int(args.idx))
     else:
         pe = dbm.get_pipe_element(pe_id)
     super().__init__(pe, dbm)
     logfile_path = self.file_man.get_pipe_log_path(self._pipe.idx)
     self._logger = log.get_file_logger(os.path.basename(pe.script.path),
                                       logfile_path)
     if self.pipe_info.logfile_path is None or not self.pipe_info.logfile_path:
         self.pipe_info.logfile_path = self.get_rel_path(logfile_path)
     self._inp = inout.Input(self)
     self._outp = inout.ScriptOutput(self)
     self.rejected_execution = False
     # If pe_id is None we have a normal script
     # If pe_id is not None a JupyterNotebook uses this script
     if pe_id is None:
         try:
             self.main()
             self.i_am_done()
             self._dbm.close_session()
         except:
             err_msg = str(datetime.datetime.now()) + '\n'
             err_msg += traceback.format_exc()
             self.report_err(err_msg)
             self._dbm.close_session()