def _connect_device_ip(ip):
    # popen返回文件对象,跟open操作一样
    with os.popen(r'adb connect ' + ip, 'r') as f:
        text = f.read()
    logd(text)  # 打印cmd输出结果
    # gdl 需要判断是否成功
    pass
Exemple #2
0
    def currentAppActivity(self):
        self.sleep(5)
        # popen返回文件对象,跟open操作一样
        cmd = r'adb -s {} shell dumpsys activity'.format(self.deviceVo.device_w)
        with os.popen(cmd, 'r') as f:
            text = f.read()
        # logd(text)  # 打印cmd输出结果
        start_pos = text.index("mFocusedActivity")
        text = text[start_pos:]
        start_pos = text.index("{") + 1
        end_pos = text.index("}\n")
        text = text[start_pos:end_pos]

        temps = text.split(" ")

        for t in temps:
            if t.__contains__("/"):
                text = t
                continue
                pass
            pass
        temps = text.split("/")
        logd(temps)
        # gdl 需要判断是否成功
        return temps[0], temps[1]
        pass
Exemple #3
0
 def home(self):
     # popen返回文件对象,跟open操作一样
     cmd = r'adb -s {} shell input keyevent 3'.format(self.deviceVo.device_w)
     with os.popen(cmd, 'r') as f:
         text = f.read()
     logd(text)
     pass
def _open_device_port(device):
    # popen返回文件对象,跟open操作一样
    with os.popen(r'adb -s ' + device + r' tcpip ' + device_client_port,
                  'r') as f:
        text = f.read()
    logd(text)  # 打印cmd输出结果
    # gdl 需要判断是否成功
    pass
Exemple #5
0
 def click(self, x_, y_):
     x = str(x_)
     y = str(y_)
     cmd = r'adb -s {} shell input tap {} {}'.format(self.deviceVo.device_w, x, y)
     with os.popen(cmd, 'r') as f:
         text = f.read()
     logd(text)  # 打印cmd输出结果
     # gdl 需要判断是否成功
     pass
    def count_device(self, device_u, device_w):
        self.cursor().execute("select * from " + self.name() + " where device_u =? or device_w =?",
                              (device_u, device_w))
        result = self.cursor().fetchall()
        logd(result)
        if result is None:
            return 0

        return len(result)
        pass
Exemple #7
0
    def forceClose(self):

        # popen返回文件对象,跟open操作一样
        cmd = r'adb -s {} shell am force-stop {}'.format(self.deviceVo.device_w, self.package())
        with os.popen(cmd, 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果
        # gdl 需要判断是否成功
        self.openWait()
        pass
Exemple #8
0
 def swipeHNxtPage(self):
     fromx = str(self.screenVo.border_right)
     y = str(self.screenVo.h5)
     tox = str(self.screenVo.border_left)
     cmd = r'adb -s {} shell input swipe {} {} {} {} {}'.format(self.deviceVo.device_w, fromx, y, tox, y,
                                                                self.speed_fast)
     with os.popen(cmd, 'r') as f:
         text = f.read()
     logd(text)  # 打印cmd输出结果
     # gdl 需要判断是否成功
     pass
Exemple #9
0
 def swipeVNxt5_1(self):
     x = str(self.screenVo.border_right)
     fromy = str(self.screenVo.h6)
     toy = str(self.screenVo.h3)
     cmd = r'adb -s {} shell input swipe {} {} {} {} {}'.format(self.deviceVo.device_w, x, fromy, x, toy,
                                                                self.speed_slow)
     with os.popen(cmd, 'r') as f:
         text = f.read()
     logd(text)  # 打印cmd输出结果
     # gdl 需要判断是否成功
     pass
Exemple #10
0
    def open(self):
        self.colse()

        # popen返回文件对象,跟open操作一样
        cmd = r'adb -s {} shell am start -n {}/{}'.format(self.deviceVo.device_w, self.package(), self.launcher())
        with os.popen(cmd, 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果
        # gdl 需要判断是否成功
        self.openWait()
        pass
 def select_id(self, id):
     self.cursor().execute("select * from " + self.name() + " where id =? ", id)
     result = self.cursor().fetchone()
     logd(result)
     if result is None:
         return
     res = DeviceVo()
     res.id = result['id']
     res.device_u = result['device_u']
     res.device_w = result['device_w']
     return res
     pass
Exemple #12
0
    def dump(self):

        cmd = r'adb -s {} shell uiautomator dump'.format(self.deviceVo.device_w)
        with os.popen(cmd, 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果
        # gdl 需要判断是否成功
        temps = text.split(":")
        res = "D:\\xml\\"

        self.pull(temps[1], res)
        pass
Exemple #13
0
    def screenshot(self):
        cmd = r'adb -s {} exec-out screencap -p /sdcard/temp.jpg'.format(self.deviceVo.device_w)

        with os.popen(cmd, 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果

        res = "D:\\xml\\"

        self.pull("/sdcard/temp.jpg", res)
        # self. resizeImage()
        pass
Exemple #14
0
    def pull(self, src, res):
        src = src.replace("\n", "")
        if not os.path.exists(res):
            os.makedirs(res)
            pass

        cmd = r'adb -s {} pull {} {}'.format(self.deviceVo.device_w, src, res)

        with os.popen(cmd, 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果
        pass
    def count(self, device, record_app, record_name):
        now0 = int(time.mktime(datetime.date.today().timetuple()))
        self.cursor().execute(
            "select * from " + self.name() +
            " where device=? and record_app =? and record_name=? and record_finish>?",
            (device, record_app, record_name, now0))
        result = self.cursor().fetchall()
        logd(result)
        if result is None:
            return 0

        return len(result)
        pass
Exemple #16
0
 def select_id(self, id):
     self.cursor().execute("select * from " + self.name() + " where id =? ",
                           id)
     result = self.cursor().fetchone()
     logd(result)
     if result is None:
         return
     res = ActVo()
     res.id = result['id']
     res.act_app = result['act_app']
     res.act_act = result['act_act']
     res.act_desc = result['act_desc']
     return res
     pass
Exemple #17
0
 def select_task(self, act_app, act_act):
     self.cursor().execute(
         "select * from " + self.name() +
         " where  act_app =? and act_act=?", (act_app, act_act))
     result = self.cursor().fetchone()
     logd(result)
     if result is None:
         return
     res = ActVo()
     res.id = result['id']
     res.act_app = result['act_app']
     res.act_act = result['act_act']
     res.act_desc = result['act_desc']
     return res
     pass
def _get_device_ip(device):
    # popen返回文件对象,跟open操作一样
    with os.popen(r'adb -s ' + device + r' shell ifconfig "| grep Mask"',
                  'r') as f:
        text = f.read()
    logd(text)  # 打印cmd输出结果

    # 输出结果字符串处理
    start_pos = text.index(':') + 1
    end_pos = text.index(' ', start_pos)

    ip = text[start_pos:end_pos].strip()

    return ip + ":5555"

    pass
 def select_id(self, id):
     self.cursor().execute("select * from " + self.name() + " where id =? ", id)
     result = self.cursor().fetchone()
     logd(result)
     if result is None:
         return
     res = PointVo()
     res.id = result['id']
     res.device = result['device']
     res.point_app = result['point_app']
     res.point_name = result['point_name']
     res.point_x = result['point_x']
     res.point_y = result['point_y']
     res.point_swipe_times = result['point_swipe_times']
     res.point_time = result['point_time']
     return res
     pass
 def select_id(self, id):
     self.cursor().execute("select * from " + self.name() + " where id =? ",
                           id)
     result = self.cursor().fetchone()
     logd(result)
     if result is None:
         return
     res = TaskVo()
     res.id = result['id']
     res.device = result['device']
     res.task_app = result['task_app']
     res.task_name = result['task_name']
     res.task_time_jiange = result['task_time_jiange']
     res.task_finish = result['task_finish']
     res.task_times = result['task_times']
     res.task_time_use = result['task_time_use']
     return res
     pass
Exemple #21
0
    def screen_info(self):
        # popen返回文件对象,跟open操作一样
        with os.popen(r'adb -s ' + self.deviceVo.device_w + r' shell wm size', 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果

        # 输出结果字符串处理
        start_pos = text.index(':') + 1

        temps = text[start_pos:].strip().split("x")
        self.screenVo.set_wh(temps)

        # popen返回文件对象,跟open操作一样
        with os.popen(r'adb -s ' + self.deviceVo.device_w + r' shell wm density', 'r') as f:
            text = f.read()
        logd(text)  # 打印cmd输出结果
        # 输出结果字符串处理
        start_pos = text.index(':') + 1

        self.screenVo.density = float(text[start_pos:].strip()) / float(160)
        pass
def get_devices():
    # popen返回文件对象,跟open操作一样
    with os.popen(r'adb devices', 'r') as f:
        text = f.read()
    logd(text)  # 打印cmd输出结果

    # 输出结果字符串处理
    s = text.split("\n")  # 切割换行
    result = [x for x in s if x != '']  # 列生成式去掉空
    logd(result)

    connect_devices = []  # 获取设备名称
    for res in result:
        dev = res.split("\tdevice")
        if len(dev) >= 2:
            connect_devices.append(dev[0])

    if not connect_devices:
        loge('无设备连接')
    else:
        loge('查询连接设备完成')

    return connect_devices
    pass
Exemple #23
0
 def get_point(self, len=5):
     cmd = r'adb -s {} shell getevent -l -c {}'.format(self.deviceVo.device_w, len)
     with os.popen(cmd, 'r') as f:
         text = f.read()
     # logd(text)  # 打印cmd输出结果
     temps = text.split("\n")
     x1 = 0
     y1 = 0
     x2 = 0
     y2 = 0
     for t in temps:
         if not t.__contains__("/dev/input/event"):
             continue
             pass
         if not t.__contains__("EV_ABS"):
             continue
             pass
         values = t.strip().split(" ")
         if t.__contains__("ABS_MT_POSITION_X"):
             x2 = int(values[-1], 16)
             if x1 == 0:
                 x1 = x2
                 pass
             continue
             pass
         if t.__contains__("ABS_MT_POSITION_Y"):
             y2 = int(values[-1], 16)
             if y1 == 0:
                 y1 = y2
                 pass
             continue
             pass
         pass
     logd(x1 + " " + y1 + " " + x2 + " " + y2)
     return x1, y1, x2, y2
     pass
Exemple #24
0
 def __init__(self) -> object:
     _init_db()
     sql = self.create()
     logd(sql)
     self.doSql(sql)
     pass