本文整理汇总了Python中doit.doit_cmd.DoitMain.run方法的典型用法代码示例。如果您正苦于以下问题:Python DoitMain.run方法的具体用法?Python DoitMain.run怎么用?Python DoitMain.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doit.doit_cmd.DoitMain
的用法示例。
在下文中一共展示了DoitMain.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doit
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def doit(line):
"""
Run *doit* with `task_creators` from all interactive variables
(IPython's global namespace).
Examples:
>>> %doit --help ## Show help for options and arguments.
>>> def task_foo():
return {'actions': ['echo hi IPython'],
'verbosity': 2}
>>> %doit list ## List any tasks discovered.
foo
>>> %doit ## Run any tasks.
. foo
hi IPython
"""
ip = get_ipython()
# Override db-files location inside ipython-profile dir,
# which is certainly writable.
prof_dir = ip.profile_dir.location
opt_vals = {'dep_file': os.path.join(prof_dir, 'db', '.doit.db')}
commander = DoitMain(ModuleTaskLoader(ip.user_module),
extra_config={'GLOBAL': opt_vals})
commander.run(line.split())
示例2: start
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def start(self):
"""Begin executing tasks."""
if self.log_filename:
print('Output will be logged to `%s`.' % self.log_filename)
start_time = time.strftime(self.timestamp_fmt)
print('Started %s' % start_time)
if self.log_filename:
orig_stdout = sys.stdout
orig_stderr = sys.stderr
sys.stdout = self.log_file
sys.stderr = self.log_file
print('Started %s' % start_time)
doit_main = DoitMain(self)
doit_main.run(['run'])
stop_time = time.strftime(self.timestamp_fmt)
if self.log_filename:
print('Stopped %s' % stop_time)
print()
sys.stdout = orig_stdout
sys.stderr = orig_stderr
self.log_file.close()
print('Stopped %s' % stop_time)
示例3: main
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def main(argv=None):
myname = path.basename(sys.argv[0]) # @UnusedVariable
mydir = path.dirname(__file__) # @UnusedVariable
if argv is None:
argv = sys.argv[1:]
opt_vals = {} # 'dep_file': path.abspath(path.join(mydir, '.doit.db'))}
commander = DoitMain(ModuleTaskLoader(pndlcmd),
extra_config={'GLOBAL': opt_vals})
commander.run(argv)
示例4: main
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def main():
configure_test()
load_exps()
doit_main = DoitMain(CustomTaskLoader())
return doit_main.run(['run'])
示例5: test_help_plugin_name
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def test_help_plugin_name(self, capsys):
plugin = {'XXX': 'tests.sample_plugin:MyCmd'}
main = DoitMain(extra_config={'COMMAND':plugin})
main.BIN_NAME = 'doit'
returned = main.run(["help"])
assert returned == 0
out, err = capsys.readouterr()
assert "doit XXX " in out
assert "test extending doit commands" in out, out
示例6: cmd_main
# 需要导入模块: from doit.doit_cmd import DoitMain [as 别名]
# 或者: from doit.doit_cmd.DoitMain import run [as 别名]
def cmd_main(args, extra_config=None, bin_name='doit'):
if extra_config:
extra_config = {'GLOBAL': extra_config}
main = DoitMain(extra_config=extra_config)
main.BIN_NAME = bin_name
return main.run(args)