def initializeTestDevice(self): self.device_id = android.settings.DEVICES['TestDevice']['id'] try: cmd1 = os.popen ('adb devices') self.device_ids = cmd1.readlines()[1:-1] if (len(self.device_ids)==1 and 'device' in str(self.device_ids) ): self.device_id = self.device_ids[0].split('\t')[0] cmd1.close() except: print 'Failed to get adb devices.\n' Android_Test_Device = android.connect(self.device_id) #Android_Test_Device = android.connect(id=android.settings.DEVICES['TestDevice']['id']) return(Android_Test_Device)
def initializeTestDevice(self): self.device_id = android.settings.DEVICES['TestDevice']['id'] try: cmd1 = os.popen('adb devices') self.device_ids = cmd1.readlines()[1:-1] if (len(self.device_ids) == 1 and 'device' in str(self.device_ids)): self.device_id = self.device_ids[0].split('\t')[0] cmd1.close() except: print 'Failed to get adb devices.\n' Android_Test_Device = android.connect(self.device_id) #Android_Test_Device = android.connect(id=android.settings.DEVICES['TestDevice']['id']) return (Android_Test_Device)
def logcat(): #device_id = android.settings.DEVICES['TestDevice']['id'] try: cmd1 = os.popen ('adb devices') device_ids = cmd1.readlines()[1:-1] if (len(device_ids)==1 and 'device' in str(device_ids) ): device_id = device_ids[0].split('\t')[0] cmd1.close() except: print 'Failed to get adb devices.\n' a = android.connect(device_id) command = 'logcat -v threadtime' date =''.join (a.device.sh('date').split(' ')[-3].split(':')) mtime = time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time())) filename = 'logcat_%s_%s_%s.txt'%(device_id,date,mtime) a.internal.log_on_connect=[ a.internal.transport.popen(command, stdout=open(a.log.log_filename(filename), 'wb+')) ]
############################################################################### def _exec(c, g, l): exec(c, g, l) def logcat(): #device_id = android.settings.DEVICES['TestDevice']['id'] try: cmd1 = os.popen ('adb devices') device_ids = cmd1.readlines()[1:-1] if (len(device_ids)==1 and 'device' in str(device_ids) ): device_id = device_ids[0].split('\t')[0] cmd1.close() except: print 'Failed to get adb devices.\n' a = android.connect(device_id) command = 'logcat -v threadtime' date =''.join (a.device.sh('date').split(' ')[-3].split(':')) mtime = time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time())) filename = 'logcat_%s_%s_%s.txt'%(device_id,date,mtime) a.internal.log_on_connect=[ a.internal.transport.popen(command, stdout=open(a.log.log_filename(filename), 'wb+')) ] def main(): #logcat() def is_plugin(c): try: return issubclass(c,nose.plugins.Plugin) except TypeError: return False
def setUp(self): self.android = android.connect() self.screen = self.android.ui.screen()
def setUp(self): try: self.a = android.connect() except: self.a.log.debug("", "\n Set up")