本文整理汇总了Python中flexget.task.Task.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Task.execute方法的具体用法?Python Task.execute怎么用?Python Task.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexget.task.Task
的用法示例。
在下文中一共展示了Task.execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from flexget.task import Task [as 别名]
# 或者: from flexget.task.Task import execute [as 别名]
def execute(task_name, abort=False, options=None):
"""
Use to execute one test task from config.
:param abort: If `True` expect (and require) this task to abort.
"""
log.info('********** Running task: %s ********** ' % task_name)
config = manager.config['tasks'][task_name]
task = Task(manager, task_name, config=config, options=options)
try:
if abort:
with pytest.raises(TaskAbort):
task.execute()
else:
task.execute()
finally:
try:
task.session.close()
except Exception:
pass
return task
示例2: FlexGetBase
# 需要导入模块: from flexget.task import Task [as 别名]
# 或者: from flexget.task.Task import execute [as 别名]
class FlexGetBase(object):
__yaml__ = """# Yaml goes here"""
# Set this to True to get a UNIQUE tmpdir; the tmpdir is created on
# setup as "./tmp/<testname>" and automatically removed on teardown.
#
# The instance variable __tmp__ is set to the absolute name of the tmpdir
# (ending with "os.sep"), and any occurrence of "__tmp__" in __yaml__ or
# a @with_filecopy destination is also replaced with it.
__tmp__ = False
def __init__(self):
self.log = log
self.manager = None
self.task = None
self.database_uri = None
self.base_path = os.path.dirname(__file__)
def setup(self):
"""Set up test env"""
setup_once()
if self.__tmp__:
self.__tmp__ = util.maketemp() + '/'
self.__yaml__ = self.__yaml__.replace("__tmp__", self.__tmp__)
self.manager = MockManager(self.__yaml__, self.__class__.__name__, db_uri=self.database_uri)
def teardown(self):
try:
try:
self.task.session.close()
except:
pass
self.manager.shutdown()
self.manager.__del__()
finally:
if self.__tmp__:
import shutil
log.trace('Removing tmpdir %r' % self.__tmp__)
shutil.rmtree(self.__tmp__.rstrip(os.sep))
def execute_task(self, name, abort_ok=False, options=None):
"""Use to execute one test task from config"""
log.info('********** Running task: %s ********** ' % name)
config = self.manager.config['tasks'][name]
if hasattr(self, 'task'):
if hasattr(self, 'session'):
self.task.session.close() # pylint: disable-msg=E0203
self.task = Task(self.manager, name, config=config, options=options)
try:
self.task.execute()
except TaskAbort:
if not abort_ok:
raise
def dump(self):
"""Helper method for debugging"""
from flexget.plugins.output.dump import dump
#from flexget.utils.tools import sanitize
# entries = sanitize(self.task.entries)
# accepted = sanitize(self.task.accepted)
# rejected = sanitize(self.task.rejected)
print '\n-- ENTRIES: -----------------------------------------------------'
# print yaml.safe_dump(entries)
dump(self.task.entries, True)
print '-- ACCEPTED: ----------------------------------------------------'
# print yaml.safe_dump(accepted)
dump(self.task.entries, True)
print '-- REJECTED: ----------------------------------------------------'
# print yaml.safe_dump(rejected)
dump(self.task.entries, True)