当前位置: 首页>>代码示例>>Python>>正文


Python GaiaApps.kill_all方法代码示例

本文整理汇总了Python中gaiatest.GaiaApps.kill_all方法的典型用法代码示例。如果您正苦于以下问题:Python GaiaApps.kill_all方法的具体用法?Python GaiaApps.kill_all怎么用?Python GaiaApps.kill_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gaiatest.GaiaApps的用法示例。


在下文中一共展示了GaiaApps.kill_all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_up_device

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
def set_up_device(opt):
    if not opt.wifi_ssid or not opt.wifi_key or not opt.wifi_pass:
        raise ValueError('Missing --wifi options')

    mc = Marionette('localhost', opt.adb_port)
    for i in range(2):
        try:
            mc.start_session()
            break
        except socket.error:
            sh('adb forward tcp:%s tcp:%s' % (opt.adb_port, opt.adb_port))
    if opt.shell:
        from pdb import set_trace
        set_trace()
        return

    # watch out! This is how gaiatest does it.
    mc.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
    device = GaiaDevice(mc)

    device.restart_b2g()

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)
    mc.setup_touch()

    lockscreen.unlock()
    apps.kill_all()

    data_layer.enable_wifi()
    if opt.wifi_key == 'WPA-PSK':
        pass_key = 'psk'
    elif opt.wifi_key == 'WEP':
        pass_key = 'wep'
    else:
        assert 0, 'unknown key management'
    data = {'ssid': opt.wifi_ssid, 'keyManagement': opt.wifi_key,
            pass_key: opt.wifi_pass}
    data_layer.connect_to_wifi(data)

    mc.switch_to_frame()
    all_apps = set(a['manifest']['name'] for a in get_installed(apps))
    if 'Marketplace Dev' not in all_apps:
        mc.execute_script(
            'navigator.mozApps.install'
            '("https://marketplace-dev.allizom.org/manifest.webapp");')
        wait_for_element_displayed(mc, 'id', 'app-install-install-button')
        yes = mc.find_element('id', 'app-install-install-button')
        mc.tap(yes)
        wait_for_element_displayed(mc, 'id', 'system-banner')

    print 'Pushing payment prefs'
    sh('adb shell stop b2g')
    sh('adb push "%s" /data/local/user.js' % (
        os.path.join(os.path.dirname(__file__), 'payment-prefs.js')))
    sh('adb shell start b2g')

    print 'When your device reboots, Marketplace Dev will be installed'
开发者ID:flodolo,项目名称:webpay,代码行数:61,代码来源:set_up_device.py

示例2: set_up_device

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
def set_up_device(args):
    mc = get_marionette(args)
    device = GaiaDevice(mc)
    try:
        device.restart_b2g()
    except Exception:
        print ' ** Check to make sure you don\'t have desktop B2G running'
        raise

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)
    mc.setup_touch()

    lockscreen.unlock()
    apps.kill_all()

    if args.wifi_ssid:
        print 'Configuring WiFi'
        if not args.wifi_key or not args.wifi_pass:
            args.error('Missing --wifi_key or --wifi_pass option')
        args.wifi_key = args.wifi_key.upper()

        data_layer.enable_wifi()
        if args.wifi_key == 'WPA-PSK':
            pass_key = 'psk'
        elif args.wifi_key == 'WEP':
            pass_key = 'wep'
        else:
            args.error('not sure what key to use for %r' % args.wifi_key)

        data = {'ssid': args.wifi_ssid, 'keyManagement': args.wifi_key,
                pass_key: args.wifi_pass}
        data_layer.connect_to_wifi(data)

    for manifest in args.apps:
        # There is probably a way easier way to do this by adb pushing
        # something. Send me a patch!
        mc.switch_to_frame()
        try:
            data = requests.get(manifest).json()
            app_name = data['name']
            all_apps = set(a['manifest']['name'] for a in get_installed(apps))
            if app_name not in all_apps:
                print 'Installing %s from %s' % (app_name, manifest)
                mc.execute_script('navigator.mozApps.install("%s");' % manifest)
                wait_for_element_displayed(mc, 'id', 'app-install-install-button')
                yes = mc.find_element('id', 'app-install-install-button')
                mc.tap(yes)
                # This still works but the id check broke.
                # See https://bugzilla.mozilla.org/show_bug.cgi?id=853878
                wait_for_element_displayed(mc, 'id', 'system-banner')
        except Exception, exc:
            print ' ** installing manifest %s failed (maybe?)' % manifest
            print ' ** error: %s: %s' % (exc.__class__.__name__, exc)
            continue
开发者ID:nhirata,项目名称:ezboot,代码行数:58,代码来源:__init__.py

示例3: install_apps

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
    def install_apps():
        mc = get_marionette(args)
        device = GaiaDevice(mc)
        try:
            device.restart_b2g()
            print 'Your device is rebooting.'
        except Exception:
            print ' ** Check to make sure you don\'t have desktop B2G running'
            raise

        apps = GaiaApps(mc)
        apps.kill_all()

        lockscreen = LockScreen(mc)
        lockscreen.unlock()

        if args.wifi_ssid:
            print 'Configuring WiFi'
            if not args.wifi_key or not args.wifi_pass:
                args.error('Missing --wifi_key or --wifi_pass option')
            args.wifi_key = args.wifi_key.upper()

            data_layer = GaiaData(mc)
            data_layer.enable_wifi()
            if args.wifi_key == 'WPA-PSK':
                pass_key = 'psk'
            elif args.wifi_key == 'WEP':
                pass_key = 'wep'
            else:
                args.error('not sure what key to use for %r' % args.wifi_key)

            data = {'ssid': args.wifi_ssid, 'keyManagement': args.wifi_key,
                    pass_key: args.wifi_pass}
            data_layer.connect_to_wifi(data)

        # disconnect marionette client because install_app would need it
        mc.client.close()

        # install apps one by one
        for manifest in args.apps:
            args.manifest = manifest
            args.app = None
            install_app(args)
开发者ID:kumar303,项目名称:ezboot,代码行数:45,代码来源:__init__.py

示例4: install_app

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
def install_app(args):
    def confirm_installation():
        _yes_button_locator = ('id', 'app-install-install-button')

        wait_for_element_displayed(mc, *_yes_button_locator)
        mc.find_element(*_yes_button_locator).tap()
        wait_for_element_not_displayed(mc, *_yes_button_locator)

        print 'App successfully installed.'

    # marketplace loading fragment locator
    _loading_fragment_locator = ('css selector', 'div#splash-overlay')
    _search_locator = ('id', 'search-q')

    if not args.app and not args.manifest and not args.app_url:
        args.error('Provide either app name (using --app), URL of app\'s '
                   'manifest file (using --manifest) or URL of the app '
                   'on marketpalce (using --app_url).')

    mc = get_marionette(args)
    lockscreen = LockScreen(mc)
    lockscreen.unlock()

    apps = GaiaApps(mc)
    apps.kill_all()

    no_internet_error = ('Unable to download app.\nReason: You are probably '
                         'not connected to internet on your device.')

    if args.manifest:
        mc.execute_script('navigator.mozApps.install("%s")' % args.manifest)
        try:
            confirm_installation()
        except TimeoutException, exc:
            print '** %s: %s' % (exc.__class__.__name__, exc)
            args.error(no_internet_error)
        return
开发者ID:kumar303,项目名称:ezboot,代码行数:39,代码来源:__init__.py

示例5: kill_all_apps

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
def kill_all_apps(args):
    mc = get_marionette(args)
    mc.setup_touch()
    apps = GaiaApps(mc)
    apps.kill_all()
    print 'Killed all apps'
开发者ID:nhirata,项目名称:ezboot,代码行数:8,代码来源:__init__.py

示例6: set_up_device

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
def set_up_device(args):
    mc = get_marionette(args)
    device = GaiaDevice(mc)
    try:
        device.restart_b2g()
    except Exception:
        print ' ** Check to make sure you don\'t have desktop B2G running'
        raise

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)

    lockscreen.unlock()
    apps.kill_all()

    if args.wifi_ssid:
        print 'Configuring WiFi'
        if not args.wifi_key or not args.wifi_pass:
            args.error('Missing --wifi_key or --wifi_pass option')
        args.wifi_key = args.wifi_key.upper()

        data_layer.enable_wifi()
        if args.wifi_key == 'WPA-PSK':
            pass_key = 'psk'
        elif args.wifi_key == 'WEP':
            pass_key = 'wep'
        else:
            args.error('not sure what key to use for %r' % args.wifi_key)

        data = {'ssid': args.wifi_ssid, 'keyManagement': args.wifi_key,
                pass_key: args.wifi_pass}
        data_layer.connect_to_wifi(data)

    for manifest in args.apps:
        # There is probably a way easier way to do this by adb pushing
        # something. Send me a patch!
        mc.switch_to_frame()
        try:
            data = requests.get(manifest).json()
            app_name = data['name']
            all_apps = set(a['manifest']['name'] for a in get_installed(apps))
            if app_name not in all_apps:
                print 'Installing %s from %s' % (app_name, manifest)
                mc.execute_script('navigator.mozApps.install("%s");' % manifest)
                wait_for_element_displayed(mc, 'id', 'app-install-install-button')
                mc.find_element('id', 'app-install-install-button').tap()
                wait_for_element_not_displayed(mc, 'id', 'app-install-install-button')

                # confirm that app got installed
                homescreen_frame = mc.find_element(*('css selector',
                                                   'div.homescreen iframe'))
                mc.switch_to_frame(homescreen_frame)
                _app_icon_locator = ('xpath', "//li[@class='icon']//span[text()='%s']" % app_name)
                try:
                    mc.find_element(*_app_icon_locator)
                except NoSuchElementException:
                    args.error('Error: app could not be installed.')

        except Exception, exc:
            print ' ** installing manifest %s failed (maybe?)' % manifest
            print ' ** error: %s: %s' % (exc.__class__.__name__, exc)
            continue
开发者ID:andymckay,项目名称:ezboot,代码行数:65,代码来源:__init__.py

示例7: run

# 需要导入模块: from gaiatest import GaiaApps [as 别名]
# 或者: from gaiatest.GaiaApps import kill_all [as 别名]
    def run(self, script, address='localhost:2828', symbols=None,
            treeherder='https://treeherder.mozilla.org/', reset=False,
            **kwargs):
        try:
            host, port = address.split(':')
        except ValueError:
            raise ValueError('--address must be in the format host:port')

        # Check that Orangutan is installed
        self.adb_device = ADBDevice(self.device_serial)
        orng_path = posixpath.join('data', 'local', 'orng')
        if not self.adb_device.exists(orng_path):
            raise Exception('Orangutan not found! Please install it according '
                            'to the documentation.')

        self.runner = B2GDeviceRunner(
            serial=self.device_serial,
            process_args={'stream': None},
            symbols_path=symbols,
            logdir=self.temp_dir)

        if reset:
            self.runner.start()
        else:
            self.runner.device.connect()

        port = self.runner.device.setup_port_forwarding(remote_port=port)
        assert self.runner.device.wait_for_port(port), \
            'Timed out waiting for port!'

        marionette = Marionette(host=host, port=port)
        marionette.start_session()

        try:
            marionette.set_context(marionette.CONTEXT_CHROME)
            self.is_debug = marionette.execute_script(
                'return Components.classes["@mozilla.org/xpcom/debug;1"].'
                'getService(Components.interfaces.nsIDebug2).isDebugBuild;')
            marionette.set_context(marionette.CONTEXT_CONTENT)

            if reset:
                gaia_device = GaiaDevice(marionette)
                gaia_device.wait_for_b2g_ready(timeout=120)
                gaia_device.unlock()
                gaia_apps = GaiaApps(marionette)
                gaia_apps.kill_all()

            # TODO: Disable bluetooth, emergency calls, carrier, etc

            # Run Orangutan script
            remote_script = posixpath.join(self.adb_device.test_root,
                                           'orng.script')
            self.adb_device.push(script, remote_script)
            self.start_time = time.time()
            # TODO: Kill remote process on keyboard interrupt
            self.adb_device.shell('%s %s %s' % (orng_path,
                                                self.device_properties['input'],
                                                remote_script))
            self.end_time = time.time()
            self.adb_device.rm(remote_script)
        except (MarionetteException, IOError):
            if self.runner.crashed:
                # Crash has been detected
                pass
            else:
                raise
        self.runner.check_for_crashes(test_name='b2gmonkey')

        # Report results to Treeherder
        required_envs = ['TREEHERDER_KEY', 'TREEHERDER_SECRET']
        if all([os.environ.get(v) for v in required_envs]):
            self.post_to_treeherder(script, treeherder)
        else:
            self._logger.info(
                'Results will not be posted to Treeherder. Please set the '
                'following environment variables to enable Treeherder '
                'reports: %s' % ', '.join([
                    v for v in required_envs if not os.environ.get(v)]))
开发者ID:JJTC-PX,项目名称:b2gmonkey,代码行数:80,代码来源:b2gmonkey.py


注:本文中的gaiatest.GaiaApps.kill_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。