예제 #1
0
def main():

    try:
        # set up and parse arguments
        parser = argparse.ArgumentParser(description='Mozilla Powertool')
        parser.add_argument('-d', '--device', type=str, nargs='+',
                            choices=['yocto','mozilla'], required=True,
                            help="specify ammeter device to use")
        parser.add_argument('-p', '--path', type=str, default=None,
                            help="specify path to ammeter device (e.g. /dev/ttyACM0)")
        parser.add_argument('-u', '--ui', type=str, default='tk',
                            choices=['tk','cli', 'web', 'simple'], help="specify which UI to use")
        parser.add_argument('-f', '--file', type=str, default=None, help="test run config file")
        parser.add_argument('-o', '--out', type=str, default=None, help="output data file")
        parser.add_argument('-b', '--begin_experiments', action="store_true", help="begin experiments as soon as the UI has been displayed")
        parser.add_argument('-s', '--show', type=str, default='current', help="name of the sample source to display")
        args = parser.parse_args()

        # create the sample source
        source = SampleSource.create( args.device, args.path )

        # create the test suite
        suite = TestSuite.create( args.file )

        # add the sample source
        suite.addSource( source )

        # create the saver
        saver = TestSuiteSaver.create( args.out )

        # create the displayer
        ui = UI.create( args.ui, suite, args.begin_experiments, args.show )

        # run the app
        ui.run()

        # save the data
        saver.save( suite )

        # shut down the sample source
        source.close()

        sys.exit(0)

    except Exception, e:
        frame = inspect.trace()[-1]
        print >> sys.stderr, "\nException:\n from %s, line %d:\n %s\n" % (frame[1], frame[2], e)
        parser.print_help()
        sys.exit(1)
예제 #2
0
def main():
    
    try:
        # set up and parse arguments
        parser = argparse.ArgumentParser(description='Mozilla Powertool')
        parser.add_argument('-d', '--device', type=str,  default=['mozilla','yocto'], 
                            choices=['yocto','mozilla'], action='append',
                            help="specify ammeter device to use")
        parser.add_argument('-p', '--path', type=str, default=None,
                            help="specify path to ammeter device (e.g. /dev/ttyACM0)")
        parser.add_argument('-u', '--ui', type=str, required=True,
                            choices=['tk','cli'], default='cli', help="specify which UI to use")
        parser.add_argument('-f', '--file', type=str,  default=None, help="test run config file")
        parser.add_argument('-o', '--out', type=str, default=None, help="output data file")
        parser.add_argument('-s', '--show', type=str, default=None, help="name of the sample source to display")
        args = parser.parse_args()

        # create the sample source
        source = SampleSource.create( args.device, args.path )
        
        # create the test suite
        suite = TestSuite.create( args.file )

        # add the sample source
        suite.addSource( source )

        # create the saver
        saver = TestSuiteSaver.create( args.out )

        # create the displayer
        ui = UI.create( args.ui, suite, args.show )

        # run the app
        ui.run()

        # save the data
        saver.save( suite )

        # shut down the sample source
        source.close()
        
        sys.exit(0)

    except Exception, e:
        print("\nERROR: %s\n" % e)
        parser.print_help()
        sys.exit(1)