10
10
from hwtest import VERSION
12
from hwtest.gui import Gui
13
12
from hwtest.plugin import PluginManager
14
13
from hwtest.question import parse_file
15
14
from hwtest.reactor import Reactor
92
94
application_factory = Application
94
def make_parser(self):
95
parser = OptionParser(version=VERSION)
96
parser.add_option("-q", "--questions", metavar="FILE",
97
default=os.path.join(SHARE_DIR, "questions.txt"),
98
help="The file containing certification questions.")
99
parser.add_option("-d", "--data-path", metavar="PATH",
101
help="The directory to store data files in.")
102
parser.add_option("-l", "--log", metavar="FILE",
103
help="The file to write the log to.")
104
parser.add_option("--log-level",
106
help="One of debug, info, warning, error or critical.")
107
parser.add_option("-c", "--command-line",
109
help="Run the tool from the command line.")
112
def make_application(self, options):
96
def create(self, options):
113
97
log_level = logging.getLevelName(options.log_level.upper())
115
99
log_handlers.append(StreamHandler())
124
108
return self.application_factory(reactor, questions=options.questions,
125
109
data_path=data_path, log_handlers=log_handlers,
126
110
log_level=log_level)
129
"""Parse command line options, construct an application, and run it."""
130
parser = self.make_parser()
131
options = parser.parse_args(args)[0]
132
application = self.make_application(options)
134
ui = Gui(application)