Exemplo n.º 1
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)
Exemplo n.º 2
0
 def syncFile(self, *args):
     try:
         self.p4.run_sync("-f", interop.getCurrentSceneFile())
         Utils.p4Logger().info("Got latest revision for {0}".format(
             interop.getCurrentSceneFile()))
     except P4Exception as e:
         displayErrorUI(e)
Exemplo n.º 3
0
    def getPreview(self, *args):
        index = self.tableWidget.currentRow()
        item = self.fileRevisions[index]
        revision = item['revision']

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

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

        path = os.path.join(interop.getTempPath(), fileName)

        try:
            tmpPath = path
            self.p4.run_print("-o", tmpPath,
                              "{0}#{1}".format(filePath, revision))
            Utils.p4Logger().info(
                "Synced preview to {0} at revision {1}".format(
                    tmpPath, revision))
            if self.isSceneFile:
                interop.openScene(tmpPath)
            else:
                Utils.open_file(tmpPath)

        except P4Exception as e:
            displayErrorUI(e)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def onSyncLatest(self, *args):
        data = self.getSelectedTreeItemData()
        if not data:
            return

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

        try:
            self.p4.run_sync("-f", filePath)
            Utils.p4Logger().info(
                "{0} synced to latest version".format(filePath))
            self.populateFileRevisions()
        except P4Exception as e:
            displayErrorUI(e)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def run_checkoutFile(self, *args):
        for file in args[1:]:
            Utils.p4Logger().info("Processing {0}...".format(file))
            result = None
            try:
                # @ToDO set this up to use p4.at_exception_level
                result = self.p4.run_fstat(file)
            except P4Exception as e:
                pass

            try:
                if result:
                    if 'otherLock' in result[0]:
                        raise P4Exception(
                            "[Warning]: {0} already locked by {1}\"".format(
                                file, result[0]['otherLock'][0]))
                    else:
                        Utils.p4Logger().info(self.p4.run_edit(file))
                        Utils.p4Logger().info(self.p4.run_lock(file))
                else:
                    Utils.p4Logger().info(self.p4.run_add(file))
                    Utils.p4Logger().info(self.p4.run_lock(file))
            except P4Exception as e:
                displayErrorUI(e)
Exemplo n.º 9
0
 def syncAllChanged(self, *args):
     try:
         self.p4.run_sync("...")
         Utils.p4Logger().info("Got latest revisions for client")
     except P4Exception as e:
         displayErrorUI(e)