當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。