Exemple #1
0
def crawl(apk, websites, run_no):
    #util.tc()
    adb = Adb(devId)
    print('in crawl', apk)
    pkgId, apkName, browser, launAct, launMethod = apk
    datafolder = "data/%s/%s" % (pkgId, apkName)
    if os.path.exists(datafolder):
        subprocess.call(["rm", "-r", datafolder])
    os.makedirs(datafolder)
    home_folder = os.path.expanduser("~")
    # fix the permission for this
    #adb.data_pull("/data/data/%s" %pkgId,"%s/%s" %(datafolder,pkgId))
    for url in websites:
        version = browser + '_run_' + str(run_no) + 'ON_A7'
        frag = '#'
        #if not url.endswith('/'):
        #frag  = '/' + frag
        _url = url + frag + version
        print(_url)
        for i in range(4):
            adb.tap_ok()
        adb.launch_benchmark(pkgId, launAct, launMethod, _url, 200)
        #time.sleep(300)
        # chaange to previous directory
        util.kill_app(pkgId)
    adb.uninstall(pkgId)
Exemple #2
0
def crawl(apk, websites, run_no):
    adb = Adb(devId)
    print('in crawl', apk)
    pkgId, apkName, browser, launAct, launMethod = apk
    datafolder = "data/%s/%s" % (pkgId, apkName)
    if os.path.exists(datafolder):
        subprocess.call(["rm", "-r", datafolder])
    os.makedirs(datafolder)
    home_folder = os.path.expanduser("~")
    # fix the permission for this
    adb.data_pull("/data/data/%s" % pkgId, "%s/%s" % (datafolder, pkgId))
    for url in websites:
        for _run in range(run_no):
            version = browser + '_run_' + str(_run)
            frag = '#'
            if not url.endswith('/'):
                frag = '/' + frag
            _url = url + frag + version
            print(_url)
            for i in range(4):
                adb.tap_ok()
            adb.launch_url_video(pkgId, launAct, launMethod, apkName,
                                 str(_run), True, _url)
            time.sleep(5)
            #adb.data_clear(pkgId)
            adb.data_push("%s/%s" % (datafolder, pkgId), "/data/data/")
            os.chdir(home_folder + "/bperf/src/%s/%s" % (datafolder, pkgId))
            # change su -c the last part
            ###########what is this supposed to do "su -c 'mv /sdcard/%s /data/data/'"
            _cmd = """find "." -type d -empty | sed 's/\.\///g'|xargs -I {} adb -s %s shell "su -c 'mkdir -p /data/data/%s/{}'" """ % (
                devId, pkgId)
            #subprocess.call("find . -type d -empty | sed 's/\ /\\\ /g' | sed 's/\./\/data\/data\/%s/' | awk '{system(\"adb -s %s shell mkdir -p \"$0)}'" %(pkgId,devId),shell=True)
            #print('mkdir cmd --->', _cmd)
            subprocess.call(_cmd, shell=True)
            # chaange to previous directory
            os.chdir(home_folder + "/bperf/src")
            #adb.close_previous_tabs(pkgId)
            #adb.clear_cookies(pkgId)
            util.kill_app(pkgId)
    adb.uninstall(pkgId)
Exemple #3
0
            if self.mon_adapt is None:
                self.mon_adapt = util.enable_monitor()

            if self.mon_adapt is None:
                util.Error('Could not find a wireless card in monitor mode')
                self.running = False
                return None

            airbase_cmd = [
                        'airbase-ng',
                        '--essid', self.config['ap_essid'].value,
                        self.mon_adapt
                          ]
            ap_proc = util.init_app(airbase_cmd, False)
            util.Msg('Access point %s running.' % \
                                    self.config['ap_essid'].value)
            raw_input()    # block
        except KeyboardInterrupt:
            self.running = False
        except Exception, er:
            util.Error('Error with wireless AP: %s' % er)
        finally:
            util.disable_monitor()
            util.kill_app(ap_proc)

    def cli(self, parser):
        """ establish CLI options
        """
        parser.add_argument('--wap', help='Wireless access point',
                        action='store_true', default=False, dest=self.which)
Exemple #4
0
            self.mon_adapt = util.get_monitor_adapter()
            if self.mon_adapt is None:
                self.mon_adapt = util.enable_monitor()

            if self.mon_adapt is None:
                util.Error('Could not find a wireless card in monitor mode')
                return None

            airbase_cmd = [
                'airbase-ng', '--essid', self.ap_essid, self.mon_adapt
            ]
            ap_proc = util.init_app(airbase_cmd, False)
            util.Msg('Access point %s running.' % self.ap_essid)
            raw_input()  # block
        except KeyboardInterrupt:
            self.running = False
        except Exception, er:
            util.Error('Error with wireless AP: %s' % er)
        finally:
            util.disable_monitor()
            util.kill_app(ap_proc)

    def cli(self, parser):
        """ establish CLI options
		"""
        parser.add_argument('--wap',
                            help='Wireless access point',
                            action='store_true',
                            default=False,
                            dest=self.which)
Exemple #5
0
        'ip': IP,
        'deviceVoltageLow': power_led.read(),
        'deviceBatteryLow': device_battery_low.read(),
        'emitterBatteryLow': emitter_battery_low.read(),
        'bluetoothConnections': "Unknown",
        'lastSeen': str(datetime.datetime.now()),
        'pulse': last_pulse_dict,
    }


def main():
    run_client(
        BATCAVE_HOST, get_device_status, get_device_info, {
            Message.CONNECT: on_connected,
            Message.RECONNECT: on_connected,
            Message.DISCONNECT: on_disconnect,
            Message.TRIGGER_PULSE: on_trigger_pulse,
            Message.UPDATE_PULSE: on_update_pulse,
            Message.UPDATE_OVERRIDES: on_update_overrides,
            Message.DEVICE_REMOTE_CONNECT: on_remote_connect,
            Message.DEVICE_REMOTE_DISCONNECT: on_remote_disconnect,
        }, app_running)


try:
    main()
    while True:
        time.sleep(0.01)
except KeyboardInterrupt:
    kill_app()