Пример #1
0
    def setCurrentWorkspace(self, *args):
        workspacePath = QtWidgets.QFileDialog.getExistingDirectory(
            interop.main_parent_window(), "Select existing workspace")

        for client in self.p4.run_clients():
            if workspacePath.replace("\\",
                                     "/") == client['Root'].replace("\\", "/"):
                root, client = os.path.split(str(workspacePath))
                self.p4.client = client

                Utils.p4Logger().info(
                    "Setting current client to {0}".format(client))
                # REALLY make sure we save the P4CLIENT variable
                if platform.system() == "Linux" or platform.system(
                ) == "Darwin":
                    os.environ['P4CLIENT'] = self.p4.client
                    Utils.saveEnvironmentVariable("P4CLIENT", self.p4.client)
                else:
                    self.p4.set_env('P4CLIENT', self.p4.client)

                Utils.writeToP4Config(self.p4.p4config_file, "P4CLIENT",
                                      self.p4.client)
                break
        else:
            QtWidgets.QMessageBox.warning(
                interop.main_parent_window(), "Perforce Error",
                "{0} is not a workspace root".format(workspacePath))
Пример #2
0
    def createWorkspace(self, *args):
        workspaceRoot = None

        # @ToDo remove this, it's badly written right now.
        # Safer to use P4V for the initial setup to rewrite this to be more reliable

        # Give the artist 3 chances to choose a folder (assuming they choose a bad path)
        tries = 3
        i = 0
        while i < tries:
            workspaceRoot = QtWidgets.QFileDialog.getExistingDirectory(
                interop.main_parent_window(), "Specify workspace root folder")
            i += 1
            if workspaceRoot:
                break
        else:
            raise IOError("Can't set workspace")

        try:
            workspaceSuffixDialog = QtWidgets.QInputDialog
            workspaceSuffix = workspaceSuffixDialog.getText(
                interop.main_parent_window(), "Workspace",
                "Optional Name Suffix (e.g. Uni, Home):")

            Utils.createWorkspace(self.p4, workspaceRoot,
                                  str(workspaceSuffix[0]))
            Utils.writeToP4Config(self.p4.p4config_file, "P4CLIENT",
                                  self.p4.client)
        except P4Exception as e:
            displayErrorUI(e)
Пример #3
0
    def createShot(self, *args):
        shotNameDialog = QtWidgets.QInputDialog
        shotName = shotNameDialog.getText(interop.main_parent_window(),
                                          "Create Shot", "Shot Name:")

        if not shotName[1]:
            return

        if not shotName[0]:
            Utils.p4Logger().warning("Empty shot name")
            return

        shotNumDialog = QtWidgets.QInputDialog
        shotNum = shotNumDialog.getText(interop.main_parent_window(),
                                        "Create Shot", "Shot Number:")

        if not shotNum[1]:
            return

        if not shotNum[0]:
            Utils.p4Logger().warning("Empty shot number")
            return

        shotNumberInt = -1
        try:
            shotNumberInt = int(shotNum[0])
        except ValueError as e:
            Utils.p4Logger().warning(e)
            return

        Utils.p4Logger().info(
            "Creating folder structure for shot {0}/{1} in {2}".format(
                shotName[0], shotNumberInt, self.p4.cwd))
        dir = Utils.createShotFolders(self.p4.cwd, shotName[0], shotNumberInt)
        self.run_checkoutFolder(None, dir)
Пример #4
0
    def __init__(self, totalFiles, parent=interop.main_parent_window()):
        super(SubmitProgressUI, self).__init__(parent)
        self.handler = None

        self.totalFiles = totalFiles

        self.currentFile = 0
Пример #5
0
    def onRevertToSelection(self, *args):
        index = self.tableWidget.rowCount() - 1
        item = self.fileRevisions[index]
        currentRevision = item['revision']

        index = self.tableWidget.currentRow()
        item = self.fileRevisions[index]
        rollbackRevision = item['revision']

        data = self.getSelectedTreeItemData()
        if not data:
            return

        # Full path is stored in the final column
        filePath = data[-1]

        Utils.p4Logger().debug(filePath)

        desc = "Rollback #{0} to #{1}".format(currentRevision,
                                              rollbackRevision)
        if CmdsChangelist.syncPreviousRevision(self.p4, filePath,
                                               rollbackRevision, desc):
            QtWidgets.QMessageBox.information(interop.main_parent_window(),
                                              "Success",
                                              "Successful {0}".format(desc))

        self.populateFileRevisions()
Пример #6
0
def displayErrorUI(e):
    error_ui = QtWidgets.QMessageBox()
    error_ui.setWindowFlags(QtCore.Qt.WA_DeleteOnClose)

    eMsg, type = PerforceUtils.parsePerforceError(e)

    if type == "warning":
        error_ui.warning(interop.main_parent_window(), "Perforce Warning",
                         eMsg)
    elif type == "error":
        error_ui.critical(interop.main_parent_window(), "Perforce Error", eMsg)
    else:
        error_ui.information(interop.main_parent_window(), "Perforce Error",
                             eMsg)

    error_ui.deleteLater()
Пример #7
0
    def queryServerStatus(self, *args):
        try:
            result = self.p4.run_info()[0]
            text = ''.join(
                ["{0} : {1}\n".format(x, result[x]) for x in result])

            QtWidgets.QMessageBox.information(interop.main_parent_window(),
                                              "Server Info", text)
        except P4Exception as e:
            displayErrorUI(e)
Пример #8
0
        def openFirstFile(selected, error):
            if not error:
                if len(selected) == 1 and Utils.queryFileExtension(
                        selected[0], interop.getSceneFiles()):
                    if not interop.getCurrentSceneFile() == selected[0]:
                        result = QtWidgets.QMessageBox.question(
                            interop.main_parent_window(), "Open Scene?",
                            "Do you want to open the checked out scene?",
                            QtWidgets.QMessageBox.Yes
                            | QtWidgets.QMessageBox.No)

                        if result == QtWidgets.QMessageBox.StandardButton.Yes:
                            interop.openScene(selected[0])
Пример #9
0
    def querySceneStatus(self, *args):
        try:
            scene = interop.getCurrentSceneFile()
            if not scene:
                Utils.p4Logger().warning("Current scene file isn't saved.")
                return

            with self.p4.at_exception_level(P4.RAISE_ERRORS):
                result = self.p4.run_fstat("-Oa", scene)[0]
            text = ''.join(
                ["{0} : {1}\n".format(x, result[x]) for x in result])

            QtWidgets.QMessageBox.information(interop.main_parent_window(),
                                              "Scene Info", text)
        except P4Exception as e:
            displayErrorUI(e)
Пример #10
0
    def createAsset(self, *args):
        assetNameDialog = QtWidgets.QInputDialog
        assetName = assetNameDialog.getText(interop.main_parent_window(),
                                            "Create Asset", "Asset Name:")

        if not assetName[1]:
            return

        if not assetName[0]:
            Utils.p4Logger().warning("Empty asset name")
            return

        Utils.p4Logger().info(
            "Creating folder structure for asset {0} in {1}".format(
                assetName[0], self.p4.cwd))
        dir = Utils.createAssetFolders(self.p4.cwd, assetName[0])
        self.run_checkoutFolder(None, dir)
Пример #11
0
    def syncAll(self, *args):
        reply = QtWidgets.QMessageBox.warning(
            interop.main_parent_window(), 'Are you sure?',
            'Are you sure? This will force every file to redownload and can take some time to complete.',
            QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)

        if reply == QtWidgets.QMessageBox.No:
            return

        # progress = SubmitProgressUI(len(files))
        # progress.create("Submit Progress")

        # callback = TestOutputAndProgress(progress)

        # progress.show()

        try:
            self.p4.run_sync("-f", "...")
            Utils.p4Logger().info("Got latest revisions for client")
        except P4Exception as e:
            displayErrorUI(e)
Пример #12
0
    def __processClientDirectory(self, title, finishCallback, preCallback,
                                 p4command, *p4args):
        fileDialog = QtWidgets.QFileDialog(interop.main_parent_window(), title,
                                           str(self.p4.cwd))

        def onEnter(*args):
            if not Utils.isPathInClientRoot(self.p4, args[0]):
                fileDialog.setDirectory(self.p4.cwd)

        def onComplete(*args):
            selectedFiles = []
            error = None

            if preCallback:
                preCallback(fileDialog.selectedFiles())

            # Only add files if we didn't cancel
            if args[0] == 1:
                for file in fileDialog.selectedFiles():
                    if Utils.isPathInClientRoot(self.p4, file):
                        try:
                            Utils.p4Logger().info(p4command(p4args, file))
                            selectedFiles.append(file)
                        except P4Exception as e:
                            Utils.p4Logger().warning(e)
                            error = e
                    else:
                        Utils.p4Logger().warning(
                            "{0} is not in client root.".format(file))

            fileDialog.deleteLater()
            if finishCallback:
                finishCallback(selectedFiles, error)

        fileDialog.setFileMode(QtWidgets.QFileDialog.DirectoryOnly)
        fileDialog.directoryEntered.connect(onEnter)
        fileDialog.finished.connect(onComplete)
        fileDialog.show()
Пример #13
0
    def on_submit(self):
        if not self.validateText():
            QtWidgets.QMessageBox.warning(interop.main_parent_window(),
                                          "Submit Warning",
                                          "No valid description entered")
            return

        files = []
        for i in range(self.tableWidget.rowCount()):
            cellWidget = self.tableWidget.cellWidget(i, 0)
            if cellWidget.findChild(
                    QtWidgets.QCheckBox).checkState() == QtCore.Qt.Checked:
                files.append(self.fileList[i]['File'])

        keepCheckedOut = self.chkboxLockedWidget.checkState()

        progress = SubmitProgressUI(len(files))
        progress.create("Submit Progress")

        callback = TestOutputAndProgress(progress)

        progress.show()

        # self.p4.progress = callback
        # self.p4.handler = callback

        # Remove student setting from Maya .ma files
        # @ToDo make this a generic callback
        # for submitFile in files:
        #     if ".ma" in submitFile:
        #         try:
        #             pathData = self.p4.run_where(submitFile)[0]
        #             Utils.removeStudentTag(pathData['path'])
        #         except P4Exception as e:
        #             print e

        try:
            CmdsChangelist.submitChange(
                self.p4, files, str(self.descriptionWidget.toPlainText()),
                callback, keepCheckedOut)
            if not keepCheckedOut:
                clientFiles = []
                for file in files:
                    try:
                        path = self.p4.run_fstat(file)[0]
                        clientFiles.append(path['clientFile'])
                    except P4Exception as e:
                        displayErrorUI(e)

                # Bug with windows, doesn't make files writable on submit for
                # some reason
                Utils.removeReadOnlyBit(clientFiles)
            self.close()
        except P4Exception as e:
            self.p4.progress = None
            self.p4.handler = None
            displayErrorUI(e)

        progress.close()

        self.p4.progress = None
        self.p4.handler = None
Пример #14
0
 def __init__(self, parent=interop.main_parent_window()):
     super(SubmitChangeUi, self).__init__(parent)
Пример #15
0
 def __init__(self, parent=interop.main_parent_window()):
     super(OpenedFilesUI, self).__init__(parent)