本文整理汇总了Python中executor.Executor.run方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.run方法的具体用法?Python Executor.run怎么用?Python Executor.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类executor.Executor
的用法示例。
在下文中一共展示了Executor.run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LiquipyDatabase
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import run [as 别名]
class LiquipyDatabase(object):
"""
Main interface for Liquipy
"""
def __init__(self, host=DEFAULT['host'],
database=DEFAULT['database'],
username=DEFAULT['username'],
password=DEFAULT['password'],
tempDir=DEFAULT['tempDir']):
self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
self.tempDir = tempDir
self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"
def initialize(self, yamlPath):
rawYaml = open(yamlPath, 'r').read()
try:
changes = yaml.load(rawYaml)
except yaml.scanner.ScannerError as e:
msg = "Error parsing input YAML file '%s':\n%s" % (yamlPath, e)
raise Exception(msg)
changeSetWriter = ChangeSetWriter(self.outputXmlChangeLogFilePath)
changeSetWriter.write(changes)
def update(self):
self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, 'update')
示例2: LiquipyDatabase
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import run [as 别名]
class LiquipyDatabase(object):
"""
Main interface for Liquipy
"""
def __init__(
self,
host=DEFAULT["host"],
database=DEFAULT["database"],
username=DEFAULT["username"],
password=DEFAULT["password"],
tempDir=DEFAULT["tempDir"],
):
self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
self.tempDir = tempDir
self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"
def initialize(self, yamlPath):
self.changes = self.inputYamlToChangeSets(yamlPath)
changeSetWriter = ChangeSetWriter(self.outputXmlChangeLogFilePath)
changeSetWriter.write(self.changes)
def inputYamlToChangeSets(self, yamlPath):
rawYaml = open(yamlPath, "r").read()
try:
changes = yaml.load(rawYaml)
except yaml.scanner.ScannerError as e:
msg = "Error parsing input YAML file '%s':\n%s" % (yamlPath, e)
raise Exception(msg)
if "include" in changes.keys():
relativeTargetDir = changes["include"]["directory"]
currentDir = join(split(yamlPath)[:-1])[0]
targetDir = join(currentDir, relativeTargetDir)
try:
dirFiles = listdir(targetDir)
except Exception:
raise Exception('Included directory "' + targetDir + '" does not exist')
migrationFiles = [join(targetDir, f) for f in dirFiles if f.endswith(".yml")]
for includedMigration in migrationFiles:
includeChanges = self.inputYamlToChangeSets(includedMigration)
changes.update(includeChanges)
del changes["include"]
return changes
def update(self):
print "Running all migrations..."
self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, "update")
def rollback(self, tagName):
print "Rolling back to %s..." % (tagName,)
self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, "rollback", tagName)
def getTags(self):
return [
{"tag": self.changes[c]["tag"], "changeSet": c} for c in self.changes.keys() if "tag" in self.changes[c]
]
示例3: test_files_created
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import run [as 别名]
def test_files_created(self):
"""Test that we can run experiments and get output files"""
conf_name = 'myconf'
wl_name = 'mywl'
results_dir = os.path.join(self.te.LISA_HOME, 'results', self.res_dir,
'rtapp:{}:{}'.format(conf_name, wl_name))
if os.path.isdir(results_dir):
shutil.rmtree(results_dir)
experiments_conf = {
'confs': [{
'tag': conf_name
}],
"wloads" : {
wl_name : {
"type" : "rt-app",
"conf" : {
"class" : "profile",
"params" : {
"mytask" : {
"kind" : "Periodic",
"params" : {
"duty_cycle_pct": 10,
"duration_s": 0.2,
},
},
},
},
},
},
}
executor = Executor(self.te, experiments_conf)
executor.run()
self.assertTrue(
os.path.isdir(results_dir),
'Expected to find a directory at {}'.format(results_dir))
result_1_dir = os.path.join(results_dir, '1')
self.assertTrue(
os.path.isdir(result_1_dir),
'Expected to find a directory at {}'.format(result_1_dir))
示例4: range
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import run [as 别名]
m = re.search(pattern, content)
li = m.group(1).splitlines()
ret = []
for i in range(len(li)):
if len(li[i]) > 0:
if li[i][0] == "*":
li[i] = li[i][1:]
#remove space
li[i] = li[i].strip()
ret.append(li[i])
return ret;
if __name__ == '__main__':
masterBot = 'Utilisateur:Hermit Crab'
wiki = Wiki('Utilisateur:Hermit Crab', 'poulpe')
#Retrieve workers in main page
bots = readBots(wiki.readPage(masterBot));
pBots = [];
for b in bots:
name = b.strip()
name = name[2:len(name)-2]
pBots.append(Bot(name,wiki.readPage(name)))
exe = Executor(wiki,pBots)
exe.run()
示例5: main
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import run [as 别名]
def main():
# parse command line
option = parse_cmdline()
filtered_devices_id = option.devices
is_list_devices = int(option.list_devices)
filtered_cases_id = option.cases
is_list_cases = int(option.list_cases)
case_file = option.case_file
executable = option.executable
# check command line
if is_list_devices:
list_devices(is_list_devices)
return
if is_list_cases:
list_cases(is_list_cases)
return
if not os.path.isfile(executable):
print "Error: " + executable + " doesn't exist."
return
# parse cases
all_cases = CaseSet()
if (case_file != ""):
all_cases.parse_xml(os.path.join(os.path.dirname(__file__), case_file))
else:
all_cases.parse_xml_dir(os.path.join(os.path.dirname(__file__), "..", "cases"))
filtered_case_set = {}
if filtered_cases_id:
for c in filtered_cases_id:
if c in all_cases.keys():
filtered_case_set[c] = all_cases[c]
else:
print "Warning: " + c + " is not an legal case ID."
else:
filtered_case_set = all_cases
# parse devices
all_devices = DeviceSet()
all_devices.parse_xml(os.path.join(os.path.dirname(__file__), "..", "devices", "devices.xml"))
filtered_device_set = {}
for d in filtered_devices_id:
if d in all_devices.keys():
filtered_device_set[d] = all_devices[d]
else:
print "Warning: " + d + " is not an legal device ID."
# execute profiling
e = Executor(executable, filtered_device_set, filtered_case_set, duplicate=10)
try:
logfiles = e.run()
except (KeyboardInterrupt):
print "KeyboardInterrupt in run.main()"
sys.exit()
# analyze log
for case_id in logfiles.keys():
for device_id in logfiles[case_id].keys():
case = all_cases[case_id]
root_node = case.get_root_node()
coeff = case.get_mcps_norm_coeff()
interest_nodes = option.interest_nodes
ana = Analyzer(root_node, coeff, interest_nodes)
if len(logfiles[case_id][device_id]) > 0:
ana.run(logfiles[case_id][device_id])
print "Finished! \nSee profile logs here: "
for dir in e.get_reports_dir():
print "\t./" + dir