def check_monkey(self, event): if check_devices(): self.monkey_p = commands.getoutput( 'adb -s %s shell ps | grep monkey' % self.current_device()) if self.monkey_p != "": pid = self.remove_item(self.monkey_p.split(' '), '')[1] log.info('Monkey pid = ' + pid) return True, pid else: log.info('No monkey process running!') return False
def stop_logcat(self, event): if check_devices(): self.logcat_p = commands.getoutput( 'adb -s %s shell ps | grep logcat' % self.current_device()) if self.logcat_p != "": for i in self.logcat_p.strip().split('\r'): pid = self.remove_item(i.split(' '), '')[1] log.info('Logcat pid = ' + pid) commands.getoutput('adb -s %s shell kill %s' % (self.current_device(), pid)) else: log.info('No logcat process running!')
def get_devices(): devices_list = [] if check_devices(): d_list = commands.getstatusoutput('adb devices') result = d_list[1].split('\n')[1:] for info in result: phone_name = info.split('\t')[0] if phone_name != "": cmd = 'adb -s %s -d shell getprop ro.product.model' % phone_name device_type = commands.getoutput(cmd).strip() devices_list.append(' - '.join([device_type, phone_name])) return devices_list
def begin_monkey(self, event): if check_devices(): self.start_new_thread(self.normal_monkey) else: log.warn('Please check the device connection!')