blob: 07fba104c1448113b1a10ff037ab73b0442a0eec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
##############################################################################
# Copyright (c) 2016 ZTE Corp and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from qtip.base.constant import PkgName, PropName
from qtip.base.error import NotFound
from qtip.collector.logfile import LogfileCollector
from qtip.driver.sample import SampleDriver
from qtip.loader.base import BaseLoader
from qtip.reporter.console import ConsoleReporter
class BaseRunner(BaseLoader):
def __init__(self, name, paths=None, config=None):
super(BaseRunner, self).__init__(name, paths=paths)
if config is None:
config = self.content[PropName.CONFIG]
driver_name = config[PropName.DRIVER]
collector_name = config[PropName.COLLECTOR]
reporter_name = config[PropName.REPORTER]
# TODO(yujunz) dynamically load modules by name
if driver_name == 'sample':
self.driver = SampleDriver()
else:
raise NotFound(driver_name, package=PkgName.DRIVER)
if collector_name == 'logfile':
self.collector = LogfileCollector()
else:
raise NotFound(collector_name,
package=PkgName.COLLECTOR)
if reporter_name == 'console':
self.reporter = ConsoleReporter()
else:
raise NotFound(reporter_name,
package=PkgName.REPORTER)
|