コード例 #1
0
ファイル: __main__.py プロジェクト: gitGNU/gnu_traydevice
    def __init__(self):
        """
            Initialize traydevice, parse command line, read configuration
        """
        _prog = "%prog"
        parser = OptionParser(usage="%prog [options] <device_file>",
                              version="%s %s" % (_prog, package_version))
        default_config_name = 'default.xml'
        parser.add_option(
            '-c',
            '--configfile',
            dest='configfile',
            help='read configuration from FILE instead of default in %s' %
            get_config_file(default_config_name, True),
            metavar='FILE')
        (opts, args) = parser.parse_args()
        if not opts.configfile:
            configfile = get_config_file(default_config_name)
        else:
            configfile = opts.configfile

        if len(args) != 1:
            logging.getLogger(__name__).error(
                'device_file argument is required')
            sys.exit(1)
        try:
            configuration = self.__open_configuration(configfile)
        except Exception as e:
            logging.getLogger(__name__).error(
                'Cannot read configuration file \'%s\' (%s)' % (configfile, e))
            sys.exit(1)
        try:
            configured_backend = configuration.xpath('/traydevice/@backend')
            if configured_backend:
                self.device = device.create_device(args[0], self,
                                                   configured_backend[0])
            else:
                self.device = device.create_device(args[0], self)
        except Exception as e:
            logging.getLogger(__name__).exception(
                'Cannot access device \'%s\'' % args[0])
            sys.exit(1)
        try:
            self.gui = gui.DeviceGui(configuration, self.device)
        except Exception as e:
            logging.getLogger(__name__).exception('Gui construction failed.')
            #            logging.getLogger(__name__).error(
            #                'Gui construction failed. (%s)' % e)
            sys.exit(1)
コード例 #2
0
def run_console():
    if len(sys.argv) > 1:
        serial = sys.argv[1]
    else:
        serial = None

    dev = device.create_device(serial)
    if dev.kind == 'adb':
        appdb.collect_apps("../apks/")
    elif dev.kind == 'web':
        appdb.load_urls("../etc/urls.txt")
    ob = observer.Observer("../err/")
    init_state = state.State()
    env = environ.Environment()
    tlib = testlib.collect_pieces("../tlib/")
    tlib.assume_reached('signin', 'login', 'main')
    tlib.assume_reached('welcome', 'skip sign in / sign up', 'main')
    ob.tlib = tlib
    init_env = {'dev': dev, 'ob': ob, 'state': init_state,
                'env': env, 'tlib': tlib}
    if len(sys.argv) > 2:
        app = sys.argv[2]
        load_app(app, ob, tlib, init_env)

    cons = console.Console(handle_console_cmd, prompt="op> ", after_cb=update_prompt,
                           init_env=init_env)
    cons.start()
    cons.wait()
コード例 #3
0
    def create_new_device(self, position, network_device):
        self.model[position] = device.create_device(network_device)

        return

        ##    def load_router(self):
        ##
        ##        self.model["A1"] = device.create_device("R","white")
        ##        return
        ##
        ##    def load_switch(self):
        ##        switch = device.create_device(Switch,"white")
        ##        #switch = device.Switch("White")
        ##        return

        ##    def update_game_statistics(self,device, device_at_destination, initial_pos, final_pos):
        self.model.update_game_statistics(device, device_at_destination,
                                          initial_pos, final_pos)
        return
コード例 #4
0
 def reset_to_initial_locations(self):
     self.clear()
     for position, value in START_PIECES_POSITION.items():
         self[position] = device.create_device(value)
         self[position].keep_reference(self)
コード例 #5
0
ファイル: miner.py プロジェクト: marklang1993/appflow
    logformat = "%(levelname).4s %(asctime)-15s %(module)10s: %(message)s"
    if args.log:
        logging.basicConfig(level=loglevel,
                            format=logformat,
                            filename=args.log)
    else:
        logging.basicConfig(level=loglevel, format=logformat)

    if args.tag:
        tagged = set(args.tag.split(','))
        tagged.add(args.app)
    else:
        tagged = None

    if args.state:
        progress.init(args.state)
    tags.load(os.path.join(args.parampath, "tags.txt"))
    value.init_params(args.parampath, args.app)
    dev = device.create_device(serial=args.serial)
    if dev.kind == 'adb':
        appdb.collect_apps(args.apkspath)
    elif dev.kind == 'web':
        appdb.load_urls(os.path.join(args.parampath, "urls.txt"))
    miner = Miner(dev, args.guispath, args.modelpath, args.tlibpath,
                  args.batch, args.app, args.statpath, args.errpath,
                  args.skippath, args.extrapath, args.mempath, True)
    if args.explore:
        miner.explore_mode()
    else:
        miner.mine(tagged, args.rounds)