|
def get_latest_package(self, path, filename):
"""
在Jenkins下载最新的安装包
"""
apk_path = os.path.join(sys.path[0], filename)
if os.path.exists(apk_path):
os.remove(filename)
url = 'http://xxx:8080/job/xxx/lastSuccessfulBuild/artifact/xxx/app/build/outputs/apk/'
response = urllib.urlopen(url)
the_page = response.read()
soup = BeautifulSoup(the_page, 'html.parser')
all_a = soup.find_all('a')
apk_filename = ''
build_id = " "
for a in all_a:
if a.text.strip().startswith('#'):
build_id = a.text.strip().replace("#","")
if a.text.strip().endswith('release.apk'):
apk_filename = a.text.strip()
break
full_filename = os.path.join(path, filename)
build_id = build_id + " ;包名:" + apk_filename
full_url = '%s/%s' %(url, apk_filename)
urllib.urlretrieve(full_url, full_filename)
return full_filename, build_id
def get_keyboard_present_status(self, device_name):
"""
通过adb命令获取键盘状态
"""
system_name = platform.system()
if system_name.lower() == 'windows':
cmdline = 'adb -s %s shell dumpsys input_method | findstr mInputShown' %device_name
else:
cmdline = 'adb -s %s shell dumpsys input_method | grep mInputShown' %device_name
my_print = os.popen(cmdline).read()
if my_print.find('mInputShown=true') != -1:
return True
return False
def adb_input_text(self, device_name, set_value, get_value=""):
"""
通过adb命令对输入框输入值
"""
if get_value != "":
txt_len = len(get_value)
cmdline = 'adb -s %s shell input keyevent 123' % device_name
for i in range(txt_len):
cmdline += ' & adb -s %s shell input keyevent 67' % device_name
cmdline += ' & adb -s %s shell input text %s' % (device_name, set_value)
else:
cmdline = 'adb -s %s shell input text %s' % (device_name, set_value)
print cmdline
os.system(cmdline)
def get_devicename(self):
"""
通过adb命令获取设备名
"""
# os.system("adb devices")
devicename = ""
my_print = os.popen("adb devices").read()
print_lists = my_print.split("\n")
if len(print_lists) > 3:
devicename = print_lists[1].split("\t")[0]
print devicename
return devicename |
|
|