Пример #1
0
    def WriteEXcleData(self, listdata=[], **kw):

        if os.path.exists(self._excelpath):
            pass
        else:
            self._excelpath = "Res/report.xls"
            logger.exception(
                "The file does not exist and the default path is used[report.xls]"
            )
        if listdata == self.listdata:
            exceldata = self.ReadEXcleBasis()
            w_xls = copy(exceldata)
            w_xls.save(self._excelpath)
        else:
            try:
                wb = xlwt.Workbook(encoding='utf-8')
                sh = wb.add_sheet("Report")
                for i in range(0, len(listdata), 3):
                    b = listdata[i:i + 3]
                    sh.write(b[0], b[1], b[2])
            except IndexError:
                logger.exception(
                    "File data is lost, incoming data cannot be triples, illegal"
                )
            finally:
                wb.save(self._excelpath)
Пример #2
0
 def dir(self):
     try:
         for parent, dirnames, filenames in os.walk(self.path,
                                                    followlinks=False):
             for x in dirnames:
                 self.dirlist.append(x)
         return self.dirlist
     except OSError as reason:
         logger.exception('出错啦!' + str(reason))
Пример #3
0
 def selectconfig(self):
     try:
         file = QFileDialog()
         file.setFileMode(QFileDialog.AnyFile)
         file.setFilter(QDir.Files)
         if file.exec_():
             filename = file.selectedFiles()
             PATHDATA['config'] = filename[0]
             self.configLable.setText(filename[0])
     except IOError:
         logger.exception("选择数据不符规则数据无效")
Пример #4
0
    def selectcase(self):
        try:
            file = QFileDialog()
            file.setFileMode(QFileDialog.AnyFile)
            file.setFilter(QDir.Files)
            if file.exec_():
                filename = file.selectedFiles()
                if PATHDATA['TestCase'] != filename[0]:
                    self.pathchanged.emit()

                    PATHDATA['TestCase'] = filename[0]
                    self.caseLable.setText(filename[0])
                else:
                    pass
        except IOError:
            logger.exception("选择数据不符规则数据无效")
Пример #5
0
 def ReadEXcleData(self):
     self.listdata = []
     if self.ReadEXcleBasis() == None:
         return self.listdata
     else:
         try:
             data = self.ReadEXcleBasis()
             table = data.sheet_by_index(0)
             for h in range(table.nrows):
                 for l in range(table.ncols):
                     self.listdata.append(h)
                     self.listdata.append(l)
                     self.listdata.append(str(table.cell(h, l).value))
             return self.listdata
         except IOError:
             logger.exception("Read File opening exception")
             return self.listdata["1", "1", ""]
Пример #6
0
    def WriteConfigData(self, outconfdata={}, **kw):
        section = "Config"
        if outconfdata == self.confdata:
            logger.info("Configuration files are not changed to write")
        else:
            self.confdata = outconfdata
            conf = configparser.ConfigParser()
            try:
                conf.add_section(section)
                for key, value in self.confdata.items():
                    conf.set(section, str(key), str(value))
                    try:
                        with open(self._configpath, 'w') as fw:
                            conf.write(fw)
                    except IOError:
                        logger.exception(
                            "The file path does not exist and cannot be saved")

            except:
                logger.exception(
                    "File content exception incorrect writing erro")
Пример #7
0
    def myui(self):
        try:
            self.dialog = ConfigDialog()
        except:
            logger.exception("配置文件初始化错误")
        try:
            self.widget = CentralView()
            self.setCentralWidget(self.widget)
            self.widget.Screenshotsignalhide.connect(self.winhide)
            self.widget.Screenshotsignalshow.connect(self.winshow)
        except:
            self.widget = QWidget()
            self.setCentralWidget(self.widget)
            logger.exception("测试用例初始化错误")

        exitAction = QAction(QIcon("Res/exit.png"), "退出", self)
        exitAction.setShortcut("ctrl+q")
        exitAction.setStatusTip("退出")
        exitAction.triggered.connect(qApp.quit)

        openfile = QAction(QIcon("Res/open.png"), "打开测试用例", self)
        openfile.setShortcut("ctrl+o")
        openfile.setStatusTip("打开测试用例")
        openfile.triggered.connect(self.openfile_data)

        savefile = QAction(QIcon("Res/save.png"), "保存", self)
        savefile.setShortcut("ctrl+s")
        savefile.setStatusTip("保存")
        savefile.triggered.connect(self.save)

        saveas = QAction(QIcon("Res/save.png"), "另保存", self)
        saveas.setShortcut("ctrl+s+s")
        saveas.setStatusTip("另保存")
        saveas.triggered.connect(self.save_as)

        self.runaction = QAction(QIcon("Res/run.png"), "运行", self)
        self.runaction.setShortcut("ctrl+r")
        self.runaction.setStatusTip("运行")
        self.runaction.triggered.connect(self.run)

        qtaction = QAction(QIcon("Res/qt.png"), "关于qt", self)
        qtaction.setStatusTip("关于qt")
        qtaction.triggered.connect(self.qt)

        aboutaction = QAction(QIcon("Res/aboutus.png"), "关于我们", self)
        aboutaction.setStatusTip("关于我们")
        aboutaction.triggered.connect(self.aboutus)

        self.freshenaction = QAction(QIcon("Res/aboutus.png"), "刷新", self)
        self.freshenaction.setStatusTip("刷新列表")
        self.freshenaction.setShortcut("F5")
        self.freshenaction.triggered.connect(self.Refresh)

        configaction = QAction(QIcon("Res/qt.png"), "配置", self)
        configaction.setStatusTip("配置")
        configaction.setShortcut("")
        configaction.triggered.connect(self.guide)

        filemenubar1 = self.menuBar()
        filemenu = filemenubar1.addMenu("文件")
        filemenu.addAction(openfile)
        filemenu.addAction(self.runaction)
        filemenu.addAction(savefile)
        filemenu.addAction(saveas)
        filemenu.addAction(exitAction)

        filemenubar2 = self.menuBar()
        filemenu = filemenubar2.addMenu("关于")
        filemenu.addAction(qtaction)
        filemenu.addAction(aboutaction)

        filemenubar3 = self.menuBar()
        filemenu = filemenubar3.addMenu("刷新")
        filemenu.addAction(self.freshenaction)

        timer = MyTimer()
        tb = self.addToolBar("工具栏")
        tb.addAction(self.runaction)
        tb.addAction(openfile)
        tb.addAction(savefile)
        tb.addAction(configaction)
        tb.addAction(self.freshenaction)
        tb.setMovable(True)
        tb.insertSeparator(openfile)
        tb.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        tb.addWidget(timer)

        # self.text = QTextEdit()
        # self.text.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        # self.pbar = QProgressBar(self)
        # self.pbar.setGeometry(1050, 730, 100, 20)

        self.setGeometry(100, 100, 1120, 750)
        # self.showFullScreen()
        # self.setWindowState(Qt.windowNoState|Qt.windowFullScreen)
        self.setWindowTitle("自动化")
        self.setWindowIcon(QIcon("Res/aboutus.png"))
        self.center()
        self.show()