本文整理匯總了Python中rose.popen.RosePopener.run_ok方法的典型用法代碼示例。如果您正苦於以下問題:Python RosePopener.run_ok方法的具體用法?Python RosePopener.run_ok怎麽用?Python RosePopener.run_ok使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rose.popen.RosePopener
的用法示例。
在下文中一共展示了RosePopener.run_ok方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Analyse
# 需要導入模塊: from rose.popen import RosePopener [as 別名]
# 或者: from rose.popen.RosePopener import run_ok [as 別名]
#.........這裏部分代碼省略.........
return rc, self.tasks
def check_extract(self, task):
"""Check if an extract name is present in a user method."""
for module_name, class_name, method, help in self.user_methods:
if task.extract == class_name:
return True
return False
def do_comparison(self, task):
"""Run the comparison."""
for module_name, class_name, method, help in self.user_methods:
comparison_name = ".".join([module_name, class_name])
if task.comparison == class_name:
for module in self.modules:
if module.__name__ == module_name:
comparison_inst = getattr(module, class_name)()
comparison_meth = getattr(comparison_inst, "run")(task)
return task
def do_extract(self, task, var):
"""Extract the specified data."""
for module_name, class_name, method, help in self.user_methods:
extract_name = ".".join([module_name, class_name])
if task.extract == class_name:
for module in self.modules:
if module.__name__ == module_name:
extract_inst = getattr(module, class_name)()
extract_meth = getattr(extract_inst, "run")(task, var)
return task
def _run_command(self, command):
"""Run an external command using rose.popen."""
output, stderr = self.popen.run_ok(command, shell=True)
output = "".join(output).splitlines()
return output
def _expand_tokens(self, inputstring, task, var=None):
"""Expands tokens $resultfile, $file and $kgoXfile."""
filename = ''
if var:
filename = getattr(task, var + "file")
expansions = {'resultfile': task.resultfile, 'file': filename}
for i in range(1, task.numkgofiles + 1):
key = "kgo" + str(i) + "file"
value = getattr(task, key)
expansions[key] = value
inputstring = inputstring.format(**expansions)
return inputstring
def _find_file(self, var, task):
"""Finds a file given a variable name containing the filename.
Given a variable name and task object, this returns the filename it
points to, including expanding any * characters with glob.
"""
filevar = var + "file"
if hasattr(task, filevar):
configvar = var + "fileconfig"
setattr(task, configvar, getattr(task, filevar))
filenames = glob.glob(env_var_process(getattr(task, filevar)))
if len(filenames) > 0:
setattr(task, filevar, os.path.abspath(filenames[0]))
return task