コード例 #1
0
ファイル: depends.py プロジェクト: kurtontheway/plow
    def applyDeps(self):
        size = len(self.__depOpts)
        progress = QtGui.QProgressDialog("Applying dependencies...", "Cancel",
                                         0, size, self)

        progress.setMinimumDuration(2)
        completed = True

        for i, callback in enumerate(self.__depOpts):
            progress.setValue(i)

            if progress.wasCanceled():
                completed = False
                break

            try:
                callback()

            except Exception, e:
                QtGui.QMessageBox.warning(self, "Error applying dependencies",
                                          str(e))
                LOGGER.warn(e)
                completed = False
                break

            if i % 4 == 0:
                QtGui.qApp.processEvents()
コード例 #2
0
ファイル: nodes.py プロジェクト: kurtontheway/plow
    def assignClusterToSelected(self, cluster):
        nodes = self.getSelectedNodes()
        if not nodes:
            return

        size = len(nodes)
        progress = QtGui.QProgressDialog("Setting cluster to %s..." % cluster.name, 
                                         "Cancel", 0, size, self)

        progress.setMinimumDuration(3)
        completed = True
        did_set = False

        failed = []

        try:
            for i, node in enumerate(nodes):
                progress.setValue(i)

                if progress.wasCanceled():
                    completed = False
                    break

                if node.clusterName != cluster.name:
                    try:
                        node.set_cluster(cluster)
                    except PlowError, e:
                        failed.append("%s: %s" % (node.name, e.args[0]))
                    else:
                        did_set = True

                if i % 10 == 0:
                    QtGui.qApp.processEvents()

        finally:
            progress.setValue(size)
            QtGui.qApp.processEvents()

        if failed:
            title = "Error setting cluster"
            msg = "One or more nodes could not switch clusters for the following reasons"
            showErrorList(failed, msg, title, self)

        if did_set:
            EventManager.GlobalRefresh.emit()