本文整理汇总了Python中plainbox.impl.session.SessionState.clean方法的典型用法代码示例。如果您正苦于以下问题:Python SessionState.clean方法的具体用法?Python SessionState.clean怎么用?Python SessionState.clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plainbox.impl.session.SessionState
的用法示例。
在下文中一共展示了SessionState.clean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_jobs
# 需要导入模块: from plainbox.impl.session import SessionState [as 别名]
# 或者: from plainbox.impl.session.SessionState import clean [as 别名]
def _run_jobs(self, ns, job_list, exporter, transport=None):
# Compute the run list, this can give us notification about problems in
# the selected jobs. Currently we just display each problem
matching_job_list = self._get_matching_job_list(ns, job_list)
print("[ Analyzing Jobs ]".center(80, '='))
# Create a session that handles most of the stuff needed to run jobs
try:
session = SessionState(job_list)
except DependencyDuplicateError as exc:
# Handle possible DependencyDuplicateError that can happen if
# someone is using plainbox for job development.
print("The job database you are currently using is broken")
print("At least two jobs contend for the name {0}".format(
exc.job.name))
print("First job defined in: {0}".format(exc.job.origin))
print("Second job defined in: {0}".format(
exc.duplicate_job.origin))
raise SystemExit(exc)
with session.open():
if session.previous_session_file():
if self.ask_for_resume():
session.resume()
else:
session.clean()
self._update_desired_job_list(session, matching_job_list)
if (sys.stdin.isatty() and sys.stdout.isatty() and not
ns.not_interactive):
outcome_callback = self.ask_for_outcome
else:
outcome_callback = None
runner = JobRunner(
session.session_dir,
session.jobs_io_log_dir,
outcome_callback=outcome_callback,
dry_run=ns.dry_run
)
self._run_jobs_with_session(ns, session, runner)
# Get a stream with exported session data.
exported_stream = io.BytesIO()
data_subset = exporter.get_session_data_subset(session)
exporter.dump(data_subset, exported_stream)
exported_stream.seek(0) # Need to rewind the file, puagh
# Write the stream to file if requested
self._save_results(ns.output_file, exported_stream)
# Invoke the transport?
if transport:
exported_stream.seek(0)
try:
transport.send(exported_stream.read())
except InvalidSchema as exc:
print("Invalid destination URL: {0}".format(exc))
except ConnectionError as exc:
print(("Unable to connect "
"to destination URL: {0}").format(exc))
except HTTPError as exc:
print(("Server returned an error when "
"receiving or processing: {0}").format(exc))
# FIXME: sensible return value
return 0