Exemple #1
0
    def get_screencap(self):
        """
        获取截图
        """
        if not self.check_device(): return

        path = '{0}{1}.png'.format(SCREENSHOTS_PATH, int(time.time()))

        def save_png(png_bytes):
            if self.mobile == Variables.Android:
                with open(path, 'wb') as png:
                    png.write(png_bytes)

        def is_save(end_str):
            if end_str == 'finish':
                if os.path.exists(path):
                    self.Terminal.appendPlainText('截图成功,截图已保存在:{}'.format(path))
                    QDesktopServices.openUrl(QUrl.fromLocalFile(path))
            else:
                self.Terminal.appendPlainText('{}'.format(end_str))

        Thread = WaitThread(self.screencap(path), '正在获取 {} 设备截图'.format(self.device_id), decode=False)
        PROCESS_LIST.append(Thread)
        Thread.waitSinOutBytes.connect(save_png)
        Thread.waitSinOutStr.connect(is_save)
        Thread.start()
Exemple #2
0
    def android_control(self):
        """ 开启画面投屏
        """
        if not self.check_device(): return

        if int(self.get_version().split('.')[0]) <= 5:
            self.Terminal.appendPlainText('Android 版本小于 5.0 设备无法开启画面同步功能')
            return
        self.Terminal.appendPlainText(VirtualKey)
        Thread = WaitThread(self.scrcpy(), '开启手机控制')
        PROCESS_LIST.append(Thread)
        Thread.waitSinOutStr.connect(self.data_ready)
        Thread.start()
Exemple #3
0
    def batch_uninstall_app(self):
        """ 批量删除应用
        :return:
        """
        if not self.check_device(): return

        app = self.app_list()
        if app:
            for device in self.device_list:
                cmd = self.uninstall(app, device)
                Thread2 = WaitThread(cmd, '{0} 设备正在删除应用 {1}'.format(device, app))
                PROCESS_LIST.append(Thread2)
                Thread2.waitSinOutStr.connect(self.data_ready)
                Thread2.start()
Exemple #4
0
    def install_app(self):
        """
        安装 APP
        """
        if not self.check_device(): return

        if self.mobile == Variables.iOS:
            openfile_name = QFileDialog.getOpenFileName(self.centralWidget, '选择文件', '', 'Excel files(*.ipa)')
        else:
            openfile_name = QFileDialog.getOpenFileName(self.centralWidget, '选择文件', '', 'Excel files(*.apk)')
        if openfile_name[0]:
            cmd = self.install(openfile_name[0])
            Thread = WaitThread(cmd, '{0} 设备正在安装应用 {1},请稍后...'.format(self.device_id, openfile_name[0]))
            PROCESS_LIST.append(Thread)
            Thread.waitSinOutStr.connect(self.data_ready)
            Thread.start()
Exemple #5
0
    def batch_install_app(self):
        """
        选择安装包弹窗
        """
        if not self.check_device(): return

        if self.mobile == Variables.iOS:
            openfile_name = QFileDialog.getOpenFileName(self.centralWidget, '选择文件', '', 'Excel files(*.ipa)')
        else:
            openfile_name = QFileDialog.getOpenFileName(self.centralWidget, '选择文件', '', 'Excel files(*.apk)')
        if openfile_name[0]:
            self.Terminal.appendPlainText('开始安装:{}'.format(openfile_name[0]))
            self.Terminal.appendPlainText('请勿操作等待软件安装')
            for device in self.device_list:
                cmd = self.install(openfile_name[0], device)
                Thread = WaitThread(cmd, '开始安装设备 {}'.format(device))
                PROCESS_LIST.append(Thread)
                Thread.waitSinOutStr.connect(self.data_ready)
                Thread.start()
Exemple #6
0
    def get_log_crash(self):
        """
         获取设备 Crash LOG 数据
        """
        if not self.check_device(): return
        cmd = self.crash_log(CRASHLOG_PATH)

        if self.mobile == Variables.iOS:
            self.stop_refresh()
            reply = QMessageBox.warning(self.centralWidget,
                                        "获取崩溃日志",
                                        "是否确认是否导出 iOS 崩溃日志,导出后手机内日志将清除。",
                                        QMessageBox.Yes | QMessageBox.No)
            if reply == QMessageBox.Yes:
                Thread = WaitThread(cmd, '正在导出崩溃日志')
                PROCESS_LIST.append(Thread)
                Thread.waitSinOutStr.connect(self.data_ready)
                Thread.start()
                return
        return self.invoke(cmd, background=True)
Exemple #7
0
    def export_app(self):
        """
        导出已安装 APP 安装包
        """
        if not self.check_device(): return

        app = self.app_list()
        path = '{0}{1}.apk'.format(APPLICATION_PATH, app)

        def seve_apk(file_inf):
            with open(path, 'wb+') as f:
                f.write(file_inf)

        if app:
            package = self.invoke(self.app_path(app))
            if isinstance(package, str):
                package = package.split(':')[1].strip()
                Thread = WaitThread(self.export(package), '{0} 设备正在导出应用 {1} 安装包'.format(self.device_id, app), decode=False)
                PROCESS_LIST.append(Thread)
                Thread.waitSinOutBytes.connect(seve_apk)
                Thread.start()