本文整理汇总了Python中opus_core.services.run_server.run_manager.RunManager._get_new_run_id方法的典型用法代码示例。如果您正苦于以下问题:Python RunManager._get_new_run_id方法的具体用法?Python RunManager._get_new_run_id怎么用?Python RunManager._get_new_run_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opus_core.services.run_server.run_manager.RunManager
的用法示例。
在下文中一共展示了RunManager._get_new_run_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_buttonBox_accepted
# 需要导入模块: from opus_core.services.run_server.run_manager import RunManager [as 别名]
# 或者: from opus_core.services.run_server.run_manager.RunManager import _get_new_run_id [as 别名]
def on_buttonBox_accepted(self):
path = str(self.lePath.text())
if not os.path.exists(path):
msg = 'Cannot import, %s does not exist' % path
logger.log_warning(msg)
MessageBox.warning(mainwindow = self,
text = msg,
detailed_text = '')
else:
cache_directory = path
years = []
for dir in os.listdir(cache_directory):
if len(dir) == 4 and dir.isdigit():
years.append(int(dir))
if years == []:
msg = 'Cannot import, %s has no run data'%path
logger.log_warning(msg)
MessageBox.warning(mainwindow = self,
text = msg,
detailed_text = '')
else:
start_year = min(years)
end_year = max(years)
project_name = os.environ['OPUSPROJECTNAME']
run_name = os.path.basename(path)
server_config = ServicesDatabaseConfiguration()
run_manager = RunManager(server_config)
run_id = run_manager._get_new_run_id()
resources = {
'cache_directory': cache_directory,
'description': '',
'years': (start_year, end_year),
'project_name': project_name
}
try:
run_manager.add_row_to_history(run_id = run_id,
resources = resources,
status = 'done',
run_name = run_name)
update_available_runs(self.project)
logger.log_status('Added run %s of project %s to run_activity table'%(run_name, project_name))
except:
errorInfo = formatExceptionInfo()
logger.log_error(errorInfo)
MessageBox.error(mainwindow = self,
text = 'Could not add run %s of project %s to run_activity table'%(run_name, project_name),
detailed_text = errorInfo)
self.close()
示例2: add_runs_to_services_db_from_disk
# 需要导入模块: from opus_core.services.run_server.run_manager import RunManager [as 别名]
# 或者: from opus_core.services.run_server.run_manager.RunManager import _get_new_run_id [as 别名]
def add_runs_to_services_db_from_disk(projects = None):
server_config = ServicesDatabaseConfiguration()
if server_config.protocol == 'sqlite':
datapath = paths.OPUS_DATA_PATH
for project_name in os.listdir(datapath):
if projects is not None and project_name not in projects: continue
if not os.path.isdir(os.path.join(datapath, project_name)): continue
os.environ['OPUSPROJECTNAME'] = project_name
server = DatabaseServer(server_config)
server.drop_database(database_name = 'run_activity')
server.close()
run_manager = RunManager(server_config)
baseyear_directory = os.path.join(datapath, project_name, 'base_year_data')
if os.path.exists(baseyear_directory):
years = []
if os.path.exists(baseyear_directory):
for dir in os.listdir(baseyear_directory):
if len(dir) == 4 and dir.isdigit():
years.append(int(dir))
start_year = min(years)
end_year = max(years)
run_name = 'base_year_data'
run_id = run_manager._get_new_run_id()
resources = {
'cache_directory': baseyear_directory,
'description': 'base year data',
'years': (start_year, end_year)
}
logger.log_status('Adding run %s of project %s to run_activity table'%(run_name, project_name))
run_manager.add_row_to_history(run_id = run_id,
resources = resources,
status = 'done',
run_name = run_name)
data_directory = os.path.join(datapath, project_name, 'runs')
if not os.path.exists(data_directory): continue
for run_name in os.listdir(data_directory):
try:
cache_directory = os.path.join(data_directory,run_name)
years = []
if not os.path.isdir(cache_directory): continue
for dir in os.listdir(cache_directory):
if len(dir) == 4 and dir.isdigit():
years.append(int(dir))
start_year = min(years)
end_year = max(years)
run_id = run_manager._get_new_run_id()
resources = {
'cache_directory': cache_directory,
'description': '',
'years': (start_year, end_year)
}
logger.log_status('Adding run %s of project %s to run_activity table'%(run_name, project_name))
run_manager.add_row_to_history(run_id = run_id,
resources = resources,
status = 'done',
run_name = run_name)
except: pass