~kelemeng/checkbox/bug868571

« back to all changes in this revision

Viewing changes to hwtest/application.py

  • Committer: Marc Tardif
  • Date: 2007-09-29 20:37:52 UTC
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: marc.tardif@canonical.com-20070929203752-5aarzgo5krdbuakk
Initial commit to refactor gui interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
from hwtest import VERSION
11
11
 
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
76
75
        persist.save(persist_filename)
77
76
        return persist
78
77
 
 
78
    def get_tests(self):
 
79
        return self.test_manager.get_iterator()
 
80
 
79
81
    def run(self):
80
82
        try:
81
83
            bpickle_dbus.install()
91
93
 
92
94
    application_factory = Application
93
95
 
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",
100
 
                          default="~/.hwtest",
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",
105
 
                          default="critical",
106
 
                          help="One of debug, info, warning, error or critical.")
107
 
        parser.add_option("-c", "--command-line",
108
 
                          default=False,
109
 
                          help="Run the tool from the command line.")
110
 
        return parser
111
 
     
112
 
    def make_application(self, options):
 
96
    def create(self, options):
113
97
        log_level = logging.getLevelName(options.log_level.upper())
114
98
        log_handlers = []
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)
127
 
 
128
 
    def run(self, args):
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)
133
 
 
134
 
        ui = Gui(application)
135
 
        ui.main()
136
 
        return 0