示例#1
0
    def _restoreFiles(self, sshcli):
        st = self.settings
        app = self.cboApp.itemText(self.cboApp.currentIndex())
        code = 0
        bakdir = dpath(app, 'backup')
        hostname = st.conf(app, 'server')
        sftpcli = None
        sshargs = {}
        if hostname not in ('localhost', '127.0.0.1'):
            sshargs = {
                'hostname': hostname,
                'username': st.conf(app, 'username'),
                'password': decrypt(st.conf(app, 'password')),
                'timeout' : 10,
                'compress': True,
                }

        try:
            if sshargs:
                if not (yield TaskOutput(u'Connecting to %s ...' % sshargs['hostname'])):
                    raise CommandTerminated()
                sshcli.set_missing_host_key_policy(AutoAddPolicy())
                sshcli.connect(**sshargs)
                if not (yield TaskOutput(u'Connected, ready to upload ...')):
                    raise CommandTerminated()
                sftpcli = sshcli.open_sftp()
            self.worker.add_step(self._uploadNew(st, app, sshcli, sftpcli, 'backup'))
        except Exception as ex:
            code = -1
            (yield TaskOutput(repr(ex), OutputType.ERROR))
        finally:
            (yield TaskOutput(u'EXIT %d' % code, OutputType.NOTIFY))
示例#2
0
    def deployNew(self):
        st = self.settings
        app = self.cboApp.itemText(self.cboApp.currentIndex())
        sshcli = SSHClient()

        hostname = st.conf(app, 'server')
        sshargs = {}
        if hostname not in ('localhost', '127.0.0.1'):
            sshargs = {
                'hostname': hostname,
                'username': st.conf(app, 'username'),
                'password': decrypt(st.conf(app, 'password')),
                'timeout' : 10,
                'compress': True,
                }

        def begin():
            self.btnDeployNew.setDisabled(True)
            self.parent().showLoading(u'Deploying Target File ... ', True)

        def end():
            if sshcli: sshcli.close()
            self.parent().showLoading('', False)
            self.btnDeployNew.setDisabled(False)

        try:
            clstemp = dpath(app, 'clstemp')
            approot = dpath(app, 'approot')
            force_rmdir(approot)
            force_rmdir(clstemp)
            mkdir_p(approot)
            mkdir_p(clstemp)
        except Exception as ex:
            self.appendLog(TaskOutput(ex.message, OutputType.ERROR))
            return

        task = Task(self._deployNew(st, app, sshargs, sshcli))
        task.init(
                TaskHandler(begin), TaskHandler(end),
                TaskHandler(self.defaultHandler),
                )
        self.worker.add_task(task)
示例#3
0
    def makeDiff(self):
        st = self.settings
        app = self.cboApp.itemText(self.cboApp.currentIndex())
        hdiff = dpath(app, 'hdiff')

        def begin():
            self.btnMakeDiff.setDisabled(True)
            self.parent().showLoading(u'Making diff files ... ', True)
        def end():
            self.parent().showLoading('', False)
            self.btnMakeDiff.setDisabled(False)
        if self.txtBugId.text() == "":
            self.appendLog(TaskOutput(u"!!! Please input Bug Id !!!", OutputType.WARN))
            return

        srcdir = self.txtSrcRoot.text()
        files = []
        tb = self.lstFiles
        for i in xrange(tb.rowCount()):
            item = tb.item(i, 0)
            if item.checkState() == Qt.Checked:
                files.append(tb.item(i, 4).text())
        cmds = [
                os.path.join("bin", "svndiff"),
                "-s", srcdir, "-d", hdiff,
                "-f", os.path.join("bin", "diff"),
                "-v", os.path.join("bin", "svn"),
                "-t", os.path.join("html", "diff_template.html"),
                ] + files

        task = Task(CmdTask(cmds))
        task.init(
                TaskHandler(begin), TaskHandler(end),
                TaskHandler(self.defaultHandler)
                )

        path = os.path.join(os.getcwdu(), hdiff).replace(os.sep, '/')
        task.put(self.echoMsg(
                u"Go to <a href='{}' style='color:dodgerblue;'>HDIFF Directory</a> "
                "to check the result.".format(path)
                ))

        st = self.settings
        bugid = self.txtBugId.text()
        rmtdir = st.conf('diff', 'remote dir')
        svnid = st.conf('svn', 'username')
        httpurl = st.conf('diff', 'http url')
        if svnid == "":
            svnid = "yanpeng.wang"
        result_url = "{}/{}/{}".format(httpurl.rstrip('/'), svnid, bugid)
        rmtdir = os.path.join(rmtdir, svnid, bugid).replace(os.sep, '/')

        sshargs = {
            'hostname': st.conf('diff', 'server'),
            'username': st.conf('diff', 'username'),
            'password': decrypt(st.conf('diff', 'password')),
            'timeout' : 10,
            'compress': True,
            }

        task.put(self._uploadDiffs(rmtdir, sshargs))
        task.put(self.echoMsg(
                u"Click <a href='{0}' style='color:dodgerblue;'>{0}</a> "
                u"to review the result.".format(result_url),
                ))

        self.worker.add_task(task)