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


Python OSCommand.executeAsyncCommand方法代码示例

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


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

示例1: stimulateWithMonkey

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def stimulateWithMonkey(self, packageName):
        """Stimulates application with monkey"""

        if self.state != AVDEmulator.STATE_STARTED:
            raise Exception("Emulator is not started.")

        if packageName is None or len(packageName)==0:
            raise Exception("Cannot stimulate package that has no name.")

        self._logger.info("Stimulating package {0} with monkey.".format(packageName))
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.emulatorSerialNumber,
            "shell",
            "monkey",
            "-p",
            packageName,
            "-v",
            "500",
            "--throttle",
            "6000",
            "--ignore-timeouts"
        ]
        OSCommand.executeAsyncCommand(cmd) 
开发者ID:Bludge0n,项目名称:hooker,代码行数:27,代码来源:AVDEmulator.py

示例2: startActivityFromPackage

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def startActivityFromPackage(self, packageName, activityName):
        """
        Starts the specified activity from the specified package name on the emulator.
        This method has to be called when package name is different from main activity.
        """

        if self.state != AVDEmulator.STATE_STARTED:
            raise Exception("Cannot start an activity since the emulator is not started.")

        if activityName is None or len(activityName)==0:
            raise Exception("Activity name is null.")

        if packageName is None or len(packageName)==0:
            raise Exception("Package name is null.")

        if not self.__checkADBRecognizeEmu():
            # self.__restartADBServer() # We cannot do that if we have multiple emulators...
            raise Exception("ADB didn't find {0}".format(self.name))
            
        self._logger.info("Starting activity {0}/{1} on emulator {2}".format(packageName, activityName, self.name))

        # $ adb shell am start -n activityPackage/activity
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.emulatorSerialNumber,
            "shell",
            "am",
            "start",
            "-n",
            "{0}/{1}".format(packageName, activityName)
        ]
        
        OSCommand.executeAsyncCommand(cmd)
开发者ID:Bludge0n,项目名称:hooker,代码行数:36,代码来源:AVDEmulator.py

示例3: startActivity

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def startActivity(self, activity):
        """Starts the specified activity on the emulator"""

        if self.state != AVDEmulator.STATE_STARTED:
            raise Exception("Cannot start an activity since the emulator is not started.")

        if activity is None or len(activity)==0:
            raise Exception("Cannot start an activity that has no name.")

        if not self.__checkADBRecognizeEmu():
            # self.__restartADBServer() # We cannot do that if we have multiple emulators...
            raise Exception("ADB didn't find {0}".format(self.name))

        self._logger.info("Starting activity {0} on emulator {1}".format(activity, self.name))

        activityPackage = '.'.join(activity.split('.')[:-1])
        activityName = ''.join(activity.split('.')[-1:])
                
        # $ adb shell am start -n activityPackage/activity
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.emulatorSerialNumber,
            "shell",
            "am",
            "start",
            "-n",
            "{0}/.{1}".format(activityPackage, activityName)
        ]
        
        OSCommand.executeAsyncCommand(cmd)
开发者ID:Bludge0n,项目名称:hooker,代码行数:33,代码来源:AVDEmulator.py

示例4: __pullResults

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
 def __pullResults(self):
     """Pull results of analysis"""
     self._logger.info("Pulling results of analysis")
     cmd = [
         self.mainConfiguration.adbPath,
         "-s",
         self.serialNumber,
         "pull",
         "/sdcard/hooker/events.logs",
         "{0}{1}-events.logs".format(self.mainConfiguration.androidTemporaryPath,
                         datetime.datetime.now().strftime("%Y-%m-%d-%H:%M"))
     ]
     OSCommand.executeAsyncCommand(cmd)
     self._logger.info("Event logs has been pulled in {0}".format(self.mainConfiguration.androidTemporaryPath))
开发者ID:AvalZ,项目名称:hooker,代码行数:16,代码来源:PhysicalDevice.py

示例5: reboot

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
 def reboot(self):
     """Reboot the device"""
     self._logger.info("Rebooting device listening on port {0}".format(self.serialNumber))
     cmd = [
         self.mainConfiguration.adbPath,
         "-s",
         self.serialNumber,
         "reboot"
     ]
     OSCommand.executeAsyncCommand(cmd)
     # Real device can take time to reboot
     time.sleep(15)
     # waits for device to be ready
     self._waitForDeviceToBeReady()
     self.state = AndroidDevice.STATE_STARTING            
开发者ID:AvalZ,项目名称:hooker,代码行数:17,代码来源:PhysicalDevice.py

示例6: start

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def start(self):
        """Starts the emulator"""
        if self.state != AndroidDevice.STATE_PREPARED:
            raise Exception("Cannot start the emulator. (expected state was {0}, current state is {1})".format(AndroidDevice.STATE_PREPARED, self.state))

        # clean the temporary directory
        self.__cleanTemporaryDirectory()
            
        cmd = [
            self.mainConfiguration.emulatorPath,
            "@{0}".format(self.name),
            "-no-snapshot-save",
            "-netspeed",
            "full",
            "-netdelay",
            "none",
            "-port",
            str(self.adbPort)
        ]
        
        self.__emulatorProcess = OSCommand.executeAsyncCommand(cmd)
        
        self.state = AndroidDevice.STATE_STARTING
        
        # Waits for device to be ready
        self._waitForDeviceToBeReady()

        # Checks that APKInstrumenter is install
        self.checkAPKInstrumenter()
开发者ID:AvalZ,项目名称:hooker,代码行数:31,代码来源:AVDEmulator.py

示例7: stimulateWithMonkey

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def stimulateWithMonkey(self, packageName):
        """Stimulates application with monkey"""
        if self.state != AndroidDevice.STATE_STARTED:
            raise Exception("Device is not started.")

        if packageName is None or len(packageName)==0:
            raise Exception("Cannot stimulate package that has no name.")

        self._logger.info("Stimulating package {0} with monkey.".format(packageName))
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.serialNumber,
            "shell",
            "monkey",
            "-p",
            packageName,
            "-v",
            "500",
            "--throttle",
            "6000",
            "--ignore-timeouts"
        ]
        p = OSCommand.executeAsyncCommand(cmd)
        stdout, stderr = p.communicate()
        self._logger.debug("{0}".format(stdout))
开发者ID:100325128,项目名称:hooker,代码行数:28,代码来源:AndroidDevice.py

示例8: startActivityFromPackage

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def startActivityFromPackage(self, packageName, activityName):
        """
        Starts the specified activity from the specified package name on the device.
        This method has to be called when package name is different from main activity.
        """
        if self.state != AndroidDevice.STATE_STARTED:
            raise Exception("Cannot start an activity since the device is not started.")

        if activityName is None or len(activityName)==0:
            raise Exception("Activity name is null.")

        if packageName is None or len(packageName)==0:
            raise Exception("Package name is null.")

        self._logger.info("Starting activity {0}/{1} on device {2}".format(packageName, activityName, self.name))

        # $ adb shell am start -n activityPackage/activity
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.serialNumber,
            "shell",
            "am",
            "start",
            "-n",
            "{0}/{1}".format(packageName, activityName)
        ]
        p = OSCommand.executeAsyncCommand(cmd)
        stdout,stderr = p.communicate()
        self._logger.debug("{0}".format(stdout))
开发者ID:100325128,项目名称:hooker,代码行数:32,代码来源:AndroidDevice.py

示例9: rebootAVD

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def rebootAVD(self):
        """Reboot the emulator"""
        self._logger.info("Rebooting AVD listening on port {0}".format(self.emulatorSerialNumber))
        cmd = [
            self.mainConfiguration.adbPath,
            "-s",
            self.emulatorSerialNumber,
            "shell",
            "setprop",
            "ctl.restart",
            "zygote"
        ]
        OSCommand.executeAsyncCommand(cmd)

        self.state = AVDEmulator.STATE_STARTING
        # waits for device to be ready
        self.__waitForDeviceToBeReady()
开发者ID:Bludge0n,项目名称:hooker,代码行数:19,代码来源:AVDEmulator.py

示例10: stop

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def stop(self, askUser=False):
        """ Stop the device"""
        self._logger.info("Stopping device listening on port {0}".format(self.serialNumber))
        clean = True
        
        # Pull our analysis events
        self.__pullResults()

        # Ask user if they want to clean the device
        if askUser:
            answer = raw_input("Do you want to clean your device? [Yes or No] ").lower()
            while answer!='yes' and answer!='no':
                answer = raw_input("Do you want to clean your device? [Yes or No] ").lower()
            if answer=='no':
                clean=False
        
        if clean:
            # If we have a real device we have to push backup to sdcard and push TWRP script to /cache/recovery/
            # at each experiment
            self.__pushBackup()
            self.__pushRecoveryScript()
            
            # reboot into recovery
            cmd = [
                self.mainConfiguration.adbPath,
                "-s",
                self.serialNumber,
                "reboot",
                "recovery"
            ]
            OSCommand.executeAsyncCommand(cmd)
            time.sleep(30)
            self._waitForDeviceToBeReady()
            
            time.sleep(5) # Wait 5 seconds to be sure SDcard will be mounted
            
            # When device is ready, don't forget to restore sdcard
            self.__restoreSDCard()
开发者ID:AvalZ,项目名称:hooker,代码行数:40,代码来源:PhysicalDevice.py

示例11: start

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
    def start(self):
        """Starts the emulator"""
        if self.state != AndroidDevice.STATE_PREPARED:
            raise Exception("Cannot start the emulator. (expected state was {0}, current state is {1})".format(AndroidDevice.STATE_PREPARED, self.state))

        # clean the temporary directory
        self.__cleanTemporaryDirectory()
        if self.__partitionSize is None:
            raise Exception("Partition size cannot be None")
        
        cmd = [
            self.mainConfiguration.emulatorPath,
            "@{0}".format(self.name),
            "-partition-size",
            str(self.__partitionSize),
            "-no-snapshot-save",
            "-netspeed",
            "full",
            "-netdelay",
            "none",
            "-port",
            str(self.adbPort)
        ]
        
        self.__emulatorProcess = OSCommand.executeAsyncCommand(cmd)
        time.sleep(2)
        if self.__emulatorProcess.poll() is not None:
            raise Exception(self.__emulatorProcess.communicate())

        self.state = AndroidDevice.STATE_STARTING
        
        # Waits for device to be ready
        self._waitForDeviceToBeReady()
        
        # Set the same time as host!
        self._logger.info("Setting emulator at the same time as host")
        localTime = datetime.datetime.now().strftime("%Y%m%d.%H%M%S")
        cmd = [
            self.mainConfiguration.adbPath, "-s", self.serialNumber, "shell", "date", "-s", localTime
        ]
        self._logger.debug(OSCommand.executeCommand(cmd))
        
        # Checks that APKInstrumenter is install
        self.checkAPKInstrumenter()
开发者ID:100325128,项目名称:hooker,代码行数:46,代码来源:AVDEmulator.py

示例12: __startAvd

# 需要导入模块: from hooker_common.OSCommand import OSCommand [as 别名]
# 或者: from hooker_common.OSCommand.OSCommand import executeAsyncCommand [as 别名]
 def __startAvd(self):
     """ Starts AVD """
     cmd = [
         self.__emulatorPath, "-avd", self.__avdName, "-partition-size", self.__partitionSize
     ]
     return OSCommand.executeAsyncCommand(cmd)
开发者ID:100325128,项目名称:hooker,代码行数:8,代码来源:HookerInstaller.py


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