Exemplo n.º 1
0
 def process_data(self, threadName, installAddr):
     rc = []
     cmd = 'adb -s %s install -r %s' % (self.device, installAddr)
     logger.info("开始安装:" + installAddr)
     Util.exccmd('adb -s %s wait-for-device ' % self.device)
     installResult = Util.exccmd(cmd)
     logger.info("安装结果:" + installResult)
Exemplo n.º 2
0
 def checkDevice(self):
     rst = Util.exccmd('adb devices | findstr '+self.device)
     if len(rst) > 1:
         logger.info("被测手机="+self.device)
     else:
         logger.error("被测手机="+self.device+"未找到")
         Util.exccmd('adb -s %s wait-for-device '%self.device)
Exemplo n.º 3
0
    def installapk(self, d, device, **installAppDict):

        for appLabelName, appTestRs in installAppDict.items():
            # mkillerpath = os.path.join("E:\\python_study\\OtaNeedInstalledApps\\com\\gionee\\ota\\request\\downloadApps",'cn.jj_5.02.02_50202.apk')
            self.logger.info(appTestRs)
            cmd = 'adb -s %s install -r %s' % (device, appTestRs[4])
            self.logger.info(cmd)
            self.logger.info("开始安装:" + appTestRs[4])
            Util.exccmd('adb -s %s wait-for-device ' % device)
            installResult = Util.exccmd(cmd)
            self.logger.info("安装结果:" + installResult)
            installAppDict[appLabelName].append(installResult)

        return installAppDict
Exemplo n.º 4
0
    def lanchAppsTest(self, testedDevice):

        curDir = sys._MEIPASS
        # apkPath = os.path.split(os.path.realpath(__file__))[0]
        apkPath = os.path.join(curDir, "AutoBvtHelper.apk")
        cmd = 'adb -s %s install -r %s' % (testedDevice, apkPath)
        logger.info("开始安装遍历应用的App:")
        installResult = Util.exccmd(cmd)
        logger.info("安装结果:" + installResult)
        time.sleep(3)
        logger.info("开始遍历所有App")
        cmd = "adb -s %s  shell am start -n gionee.autotest.autobvthelper/.view.MainActivity --ei start 1 --ei isClean 1" % testedDevice
        iterRs = Util.exccmd(cmd)
        logger.info(iterRs)
        adbLog = adblog.Adblog(testedDevice)
        adbLog.readAdbLog()
Exemplo n.º 5
0
 def finddevices(self):
     rst = Util.exccmd('adb devices')
     devices = re.findall(r'(.*?)\s+device', rst)
     if len(devices) > 1:
         deviceIds = devices[1:]
         self.logger.info('共找到%s个手机' % str(len(devices) - 1))
         for i in deviceIds:
             self.logger.info('ID为%s' % i)
         return deviceIds
     else:
         self.logger.error('没有找到手机,请检查')
Exemplo n.º 6
0
 def readAdbLog(self):
     isExit = False
     while not isExit:
         proc = subprocess.Popen(
             ['adb', 'logcat', '-v', 'time', '-s', 'gionee.os.autotest'],
             stdout=subprocess.PIPE)
         for line in proc.stdout:
             # print(line.decode('utf-8'))
             self.logger.info(line.decode('utf-8'))
             try:
                 if (str(line.decode('utf-8')).index("遍历完成") > -1):
                     cmd = "adb -s %s pull /sdcard/screenshot" % self.device
                     pullRs = Util.exccmd(cmd)
                     self.logger.info("pullRs=" + pullRs)
                     isExit = True
                     break
             except:
                 pass
         proc.wait()
Exemplo n.º 7
0
    def thirdAppsTest(self):
        xlsxFiles = Util.filterFiles(".", ['.xlsx'])
        if (len(xlsxFiles) < 1):
            logger.error("当前目录没有需要测试应用的xlsx文件")
            sys.exit()
        logger.info("当前需要测试的应用的xlsx文件:" + xlsxFiles[0])
        ec = excel.Excel(xlsxFiles[0])
        sheetNames = ec.getAllSheetNames()
        logger.info("存在的sheet有:")
        logger.info(sheetNames)
        testedProjectName = input(
            "请输入被测试的项目名称:\n ********************** \n eg:F100,金钢全网通 \n **********************\n请输入:"
        )

        if testedProjectName in sheetNames:
            logger.info("接收到项目:" + testedProjectName)
        else:
            logger.error(testedProjectName + "的sheet不存在")
            sys.exit()
        install = Install.Install()
        install.finddevices()
        testedDevice = input(
            "请输入被测试手机串号:\n ********************** \n eg:CYHAVCYLEULJB6FU \n **********************\n请输入:"
        )
        logger.info("被测手机串号:" + testedDevice)
        logger.info(begin)
        pkg_dict = ec.get_pkg_values("三方汇总表", "应用名称", "应用包名")
        testedApps = ec.get_tested_app_name(testedProjectName, "应用名称")
        # download=downloadApp.Download()
        appsMgr = AppsMgr()
        downloadFromGnAppType = 1
        downloadFromQqAppType = 2
        downloadRsDict = appsMgr.downloadApps(downloadFromGnAppType,
                                              *testedApps, **pkg_dict)
        installMgr = InstallMgr(testedDevice)
        installMgr.installApps(**downloadRsDict)
        #遍历APP并点掉弹出框

        bvtTraversal = BvtTraversal()
        bvtTraversal.lanchAppsTest(testedDevice)
Exemplo n.º 8
0
from com.gionee.ota import Base
from com.gionee.ota.excel import excel
from com.gionee.ota.request import downloadApp
import datetime
from com.gionee.ota import gol
from com.gionee.ota.util import Util
import os,sys,re
from com.gionee.ota.intall import Install
import time
import subprocess
logger = Util.logger
curDir=Base.Base.get_cur_dir(__file__)
apkPath = os.path.join(curDir,"resource","AutoBvtHelper.apk")
cmd = 'adb -s %s install -r %s'% ("CYHAVCYLEULJB6FU",apkPath)
logger.info("开始安装遍历应用的App:")
installResult = Util.exccmd(cmd)
logger.info("安装结果:"+installResult)
logger.info("开始遍历所有App")
cmd = "adb -s %s  shell am start -n gionee.autotest.autobvthelper/.view.MainActivity --ei start 1 --ei isClean 1"%("CYHAVCYLEULJB6FU")
iterRs=Util.exccmd(cmd)
time.sleep(1)
# cmd = "adb -s %s  shell ps -ef | findstr autobvthelper"%("CYHAVCYLEULJB6FU")
# rst=Util.exccmd(cmd)
# print(rst)
# proceeInfo = re.findall(r'(.*?)\s+gionee.autotest.autobvthelper',rst)
# cmd = "adb -s %s  logcat -s gionee.os.autotest"%("CYHAVCYLEULJB6FU")
# rst=Util.exccmd(cmd)
proc = subprocess.Popen(['adb', 'logcat', '-v', 'time','-s','gionee.os.autotest'], stdout=subprocess.PIPE)
for line in proc.stdout:
    print(line.decode('utf-8'))
proc.wait()
Exemplo n.º 9
0
    def doSingleInstall(self, deviceId, **installAppDict):
        d = Device(deviceId)
        installAppRsDict = self.installapk(d, deviceId, **installAppDict)
        return installAppDict

    def doInstall(self, deviceids, **installAppDict):
        count = len(deviceids)
        # port_list = range(5555,5555+count)
        deviceTestResultDict = {}
        for i in range(len(deviceids)):
            d = Device(deviceids[i])
            installAppRsDict = self.installapk(d, deviceids[i],
                                               **installAppDict)
            deviceTestResultDict[deviceids[i]] = installAppRsDict
        return deviceTestResultDict


if __name__ == "__main__":
    # cleanEnv()
    logger = Util.logger
    install = Install()
    devicelist = install.finddevices()
    print(devicelist)
    if devicelist:
        # apkpath = os.path.join(os.getcwd(),'apk')
        apklist = Util.listFile(
            "E:\\python_study\\OtaNeedInstalledApps\\com\\gionee\\ota\\request\\downloadApps"
        )
        print(apklist)
        install.doInstall(devicelist, apklist)  #每个手机都要安装apklist里的apk
Exemplo n.º 10
0
from com.gionee.ota.excel import excel
from com.gionee.ota.request import downloadApp
import datetime
from com.gionee.ota import gol
from com.gionee.ota.util import Util
import os, sys
from com.gionee.ota.intall import Install
from com.gionee.ota.request import downloadAddrMulti
from com.gionee.ota.request.downloadAppMulti import DownloadAppMulti
from com.gionee.ota.intall.installMulti import MultiInstall
if __name__ == '__main__':
    logger = Util.logger
    logger.info("\n\n")
    logger.info("**************************begin***************************")
    Base.Base.get_cur_dir(__file__)
    xlsxFiles = Util.filterFiles(".", ['.xlsx'])
    if (len(xlsxFiles) < 1):
        logger.error("当前目录没有需要测试应用的xlsx文件")
        sys.exit()
    logger.info("当前需要测试的应用的xlsx文件:" + xlsxFiles[0])
    ec = excel.Excel(xlsxFiles[0])
    sheetNames = ec.getAllSheetNames()
    logger.info("存在的sheet有:")
    logger.info(sheetNames)
    testedProjectName = input(
        "请输入被测试的项目名称:\n ********************** \n eg:F100,金钢全网通 \n **********************\n请输入:"
    )

    if testedProjectName in sheetNames:
        logger.info("接收到项目:" + testedProjectName)
    else: