Пример #1
0
class dMFXsubmitterDialog(QDialog, Ui_dMFXsubmitter):
    def __init__(self, parent=None):
        # set up the UI and variable here - don't forget to call updateUI at end
        super(dMFXsubmitterDialog, self).__init__(parent)
        self.acceptDrops()
        self.setupUi(self)  # generic call to setup the Ui provided by Qt
        self.password = ''
        self.version_file_path = ''
        self.user = ''
        self.user_id = ''
        self.user_name = ''
        self.user_initials = ''
        self.submit_movie = False
        self.movie_file_path = ''
        self.description = ''
        self.login_status = False
        self.allOK = True
        self.submit_call_track = True
        self.version_type = 'Shot'
        self.created_version_id = None
        self.sg = Shotgun(SERVER_PATH, SCRIPT_USER, SCRIPT_KEY)
        self.sgu = Shotgun(SERVER_PATH, SCRIPT_USER, SCRIPT_KEY)
        self.users_with_initals = INITIALS_LIST
        self.user_list = []
        self.lineEdit_versionFile.dragEnterEvent = types.MethodType(
            dragEnterEvent, self.lineEdit_versionFile)
        self.lineEdit_versionFile.dropEvent = types.MethodType(
            dropEvent, self.lineEdit_versionFile)
        self.lineEdit_versionFile.setAcceptDrops(True)
        self.lineEdit_versionFile.setDragEnabled(True)
        self.lineEdit_forReview.dragEnterEvent = types.MethodType(
            dragEnterEvent, self.lineEdit_forReview)
        self.lineEdit_forReview.dropEvent = types.MethodType(
            dropEvent, self.lineEdit_forReview)
        self.lineEdit_forReview.setAcceptDrops(True)
        self.lineEdit_forReview.setDragEnabled(True)

        # start things happening... get the users from sg and populate them into the drop-down
        self.update_user_list()
        self.connect(self, SIGNAL('update'), self.updateUI)

        self.new_value = 'this is not a new value'
        #self.emit(SIGNAL("update"))
        self.updateUI()

    def update_user_list(self):
        filters = [
            ['sg_status_list', 'is', 'act'],
        ]
        fields = ['name', 'login']
        users = self.sg.find('HumanUser', filters, fields)
        user_list = [(user['name'], user['login'], user['id'])
                     for user in users if user['name'] != 'Template User']
        user_list.sort()
        self.user_list = user_list
        self.comboBox_artistSelect.addItem('Please Select...')
        self.user = '******'
        for user in user_list:
            self.comboBox_artistSelect.addItem(user[0])
        self.updateUI()

    def reset_to_go_again(self):
        # todo set all fields to blank, not just update the values...
        self.version_file_path = ''
        self.submit_movie = False
        self.movie_file_path = ''
        self.description = ''
        self.allOK = True
        self.created_version_id = None
        self.plainTextEdit_description.setPlainText('')
        self.lineEdit_versionFile.setText('')
        self.lineEdit_forReview.setText('')
        self.updateUI()

    def updateUI(self):
        # make sure that the UI is updated to match input
        self.activateWindow()  # window gets keyboard focus after redraw
        self.allOK = True
        self.description = str(self.plainTextEdit_description.toPlainText())

        # check user and if it needs initials, activate the text box
        if self.user in self.users_with_initals:
            self.lineEdit_initials.setEnabled(True)
        else:
            self.lineEdit_initials.setEnabled(False)

        # check user to see if one has been selected... set login to default if it has and there is no login set
        if self.user == STARTING_USER_LIST_TEXT:
            self.pushButton_login.setEnabled(False)
        else:
            self.pushButton_login.setEnabled(True)
            if not self.login_status:
                self.pushButton_login.setDefault(True)

        # check to see if logged in - if not, disable everything below login
        if self.login_status:
            self.label_password.setText("** Logged In **")
            self.pushButton_login.setEnabled(False)
            self.comboBox_artistSelect.setEnabled(False)
        else:
            self.label_password.setText("Shotgun Password")
            self.pushButton_login.setEnabled(True)

        # check the submit checkbox and enable fields if set
        if self.checkBox_forReview.isChecked():
            self.lineEdit_forReview.setEnabled(True)
            self.pushButton_getForReview.setEnabled(True)
            self.submit_movie = True

        # check for movie submit check-box
        if self.submit_movie:
            self.lineEdit_forReview.setEnabled(True)
            self.pushButton_getForReview.setEnabled(True)
        else:
            self.lineEdit_forReview.setEnabled(False)
            self.pushButton_getForReview.setEnabled(False)

        # check for a need for initals
        if self.user in INITIALS_LIST:
            self.label_initials.setText('Add Your Initials')
            self.lineEdit_initials.show()
        else:
            self.label_initials.setText('')
            self.lineEdit_initials.hide()
            self.user_initials = ''
            self.lineEdit_initials.setText('')

        # check to see if the version file is a movie and, if so and the movie line is empty, fill that in
        if self.version_file_path and os.path.splitext(
                str(self.version_file_path).lower()
        )[1] in MOVIE_FILE_EXTENSION_LIST and not self.movie_file_path:
            self.movie_file_path = str(self.version_file_path)
            self.lineEdit_forReview.setText(self.movie_file_path)

        # check for conditions that allow an update to happen
        conditions = True  # start by assuming we can go and switch if we can't
        if self.user in INITIALS_LIST and not self.user_initials:
            conditions = False
        if conditions and not self.login_status:
            conditions = False
        if conditions and self.version_file_path and not os.path.exists(
                self.version_file_path):
            conditions = False
        if conditions and self.submit_movie:
            if self.movie_file_path and not os.path.exists(
                    self.movie_file_path):
                conditions = False
            if not self.movie_file_path:
                conditions = False

        #enable the submit button if appropriate
        if conditions:
            self.pushButton_submit.setEnabled(True)
            self.pushButton_submit.setDefault(True)
        else:
            self.pushButton_submit.setEnabled(False)

    # self.pushButton_login
    @pyqtSignature("")
    def on_pushButton_login_clicked(self):
        result = self.sgu.authenticate_human_user(
            self.user_name, self.lineEdit_password.text())
        if result:
            self.login_status = True
        else:
            # user tried to log in and failed - let them know
            QMessageBox.about(
                self, "Log In Error",
                "Unable to login to Shotgun using your user/pass combination, please try again"
            )
        self.updateUI()

    # self.pushButton_getVersionFile
    @pyqtSignature("")
    def on_pushButton_getVersionFile_clicked(self):
        self.version_file_path = str(
            QFileDialog.getOpenFileName(
                self, "Select the file to submit as a Version"))
        if self.version_file_path:
            self.lineEdit_versionFile.setText(self.version_file_path)
        self.updateUI()

    # self.pushButton_getForReview
    @pyqtSignature("")
    def on_pushButton_getForReview_clicked(self):
        self.movie_file_path = str(
            QFileDialog.getOpenFileNameAndFilter(
                self,
                "Select a movie file to submit for screening",
                filter="Movies ( *.mp4 *.mov)")
            [0])  # the getopenfile returns a tuple of length 2
        if self.movie_file_path:
            self.lineEdit_forReview.setText(self.movie_file_path)
        self.updateUI()

    # self.pushButton_quit
    @pyqtSignature("")
    def on_pushButton_quit_clicked(self):
        QApplication.quit()

    # self.checkBox_forReview
    @pyqtSignature("bool")
    def on_checkBox_forReview_clicked(self):
        #lcheckBox_forReview boolean toggle code here
        self.submit_movie = self.checkBox_forReview.isChecked()
        self.updateUI()

    # self.comboBox_artistSelect
    @pyqtSignature("QString")
    def on_comboBox_artistSelect_currentIndexChanged(self):
        if self.user:
            self.user = self.comboBox_artistSelect.currentText()
            self.user_name = [
                user[1] for user in self.user_list if user[0] == self.user
            ][0]
            self.user_id = [
                user[2] for user in self.user_list if user[0] == self.user
            ][0]
        self.updateUI()

    # self.comboBox_version_type
    @pyqtSignature("QString")
    def on_comboBox_version_type_currentIndexChanged(self):
        self.version_type = str(self.comboBox_version_type.currentText())
        self.updateUI()

    # self.lineEdit_forReview
    @pyqtSignature("QString")
    def on_lineEdit_forReview_textEdited(self):
        self.movie_file_path = str(self.lineEdit_forReview.text())
        self.emit(SIGNAL("update"))

    # self.lineEdit_initials
    @pyqtSignature("QString")
    def on_lineEdit_initials_textEdited(self):
        self.user_initials = str(self.lineEdit_initials.text())
        self.updateUI()

    # self.lineEdit_versionFile
    @pyqtSignature("QString")
    def on_lineEdit_versionFile_textEdited(self):
        self.version_file_path = str(self.lineEdit_versionFile.text())
        self.updateUI()

    # self.lineEdit_versionFile
    @pyqtSignature("QString")
    def on_lineEdit_versionFile_textChanged(self):
        self.version_file_path = str(self.lineEdit_versionFile.text())
        self.updateUI()

    # self.plainTextEdit_description
    @pyqtSignature("")
    def on_plainTextEdit_description_textEdited(self):
        self.updateUI()

    # self.pushButton_submit
    @pyqtSignature("")
    def on_pushButton_submit_clicked(self):
        if not self.submit_call_track:
            self.submit_call_track = True
            return
        else:
            self.submit_call_track = False

        sgerrmsg = "There were no matching {0}s, make sure that you have selected the right kind of entity and try again"
        if not self.allOK:
            return
        try:
            self.created_version_id = update_shotgun(
                self.sg, self.version_file_path, self.description,
                self.user_id, self.version_type, self.user_initials, self)
            if not self.created_version_id:  # sg did not find anything! Tell the user and let them try again or quit
                self.allOK = False
                sub_dialog = dMFXsubmitterSubDialog("No Matches",
                                                    "Reset",
                                                    "QUIT!",
                                                    sgerrmsg.format(
                                                        self.version_type),
                                                    boxeditable=False,
                                                    parent=self)
                button, text, pick = sub_dialog.getValues()
                if sub_dialog.exec_():
                    sub_dialog.close()
                    button, text, pick = sub_dialog.getValues()
                    if button == 'No':
                        QApplication.quit()
                    else:
                        return  # return if they click on Retry
                else:
                    return  # return if they close the window

            mainlabel = "Success!"
            yeslabel = 'Go Again'
            nolabel = 'QUIT!'
            boxtext = 'Your version was successfully created'

            if self.allOK and self.submit_movie:
                if not do_submit_for_review(self.sg, self.movie_file_path,
                                            self.created_version_id):
                    # the sym-link failed for some reason after 2 tries...
                    mainlabel = "Partial Success..."
                    boxtext = "Your version was created but the movie was NOT put into today's Review Folder. Please add it manually, or resubmit the Version"

        except Exception, e:
            mainlabel = "ERROR!"
            yeslabel = 'Reset'
            nolabel = 'QUIT!'
            boxtext = 'Something Went Horribly Wrong! -\nError: {0}\n{1}'.format(
                e, traceback.format_exc())

        #QMessageBox.about(self, "updateUI", output_string)
        sub_dialog = dMFXsubmitterSubDialog(mainlabel, yeslabel, nolabel,
                                            boxtext)
        if sub_dialog.exec_():
            sub_dialog.close()
            button, text, pick = sub_dialog.getValues()
            if button == 'No':
                QApplication.quit()
            else:
                self.reset_to_go_again()
Пример #2
0
class dMFXsubmitterDialog(QDialog, Ui_dMFXsubmitter):

    def __init__(self, parent = None):
        # set up the UI and variable here - don't forget to call updateUI at end
        super(dMFXsubmitterDialog,self).__init__(parent)
        self.acceptDrops()
        self.setupUi(self) # generic call to setup the Ui provided by Qt
        self.password = ''
        self.version_file_path = ''
        self.user = ''
        self.user_id = ''
        self.user_name = ''
        self.user_initials = ''
        self.submit_movie = False
        self.movie_file_path = ''
        self.description = ''
        self.login_status = False
        self.allOK = True
        self.submit_call_track = True
        self.version_type = 'Shot'
        self.created_version_id = None
        self.sg = Shotgun(SERVER_PATH, SCRIPT_USER, SCRIPT_KEY)
        self.sgu = Shotgun(SERVER_PATH, SCRIPT_USER, SCRIPT_KEY)
        self.users_with_initals = INITIALS_LIST
        self.user_list = []
        self.lineEdit_versionFile.dragEnterEvent = types.MethodType(dragEnterEvent,self.lineEdit_versionFile)
        self.lineEdit_versionFile.dropEvent = types.MethodType(dropEvent,self.lineEdit_versionFile)
        self.lineEdit_versionFile.setAcceptDrops(True)
        self.lineEdit_versionFile.setDragEnabled(True)
        self.lineEdit_forReview.dragEnterEvent = types.MethodType(dragEnterEvent,self.lineEdit_forReview)
        self.lineEdit_forReview.dropEvent = types.MethodType(dropEvent,self.lineEdit_forReview)
        self.lineEdit_forReview.setAcceptDrops(True)
        self.lineEdit_forReview.setDragEnabled(True)

        # start things happening... get the users from sg and populate them into the drop-down
        self.update_user_list()
        self.connect(self,SIGNAL('update'),self.updateUI)

        self.new_value = 'this is not a new value'
        #self.emit(SIGNAL("update"))
        self.updateUI()

    def update_user_list(self):
        filters = [ ['sg_status_list', 'is', 'act' ],]
        fields = ['name', 'login']
        users = self.sg.find('HumanUser', filters, fields)
        user_list = [ (user['name'],user['login'],user['id']) for user in users if user['name'] != 'Template User']
        user_list.sort()
        self.user_list = user_list
        self.comboBox_artistSelect.addItem('Please Select...')
        self.user = '******'
        for user in user_list:
           self.comboBox_artistSelect.addItem(user[0])
        self.updateUI()

    def reset_to_go_again(self):
        # todo set all fields to blank, not just update the values...
        self.version_file_path = ''
        self.submit_movie = False
        self.movie_file_path = ''
        self.description = ''
        self.allOK = True
        self.created_version_id = None
        self.plainTextEdit_description.setPlainText('')
        self.lineEdit_versionFile.setText('')
        self.lineEdit_forReview.setText('')
        self.updateUI()

    def updateUI(self):
        # make sure that the UI is updated to match input
        self.activateWindow() # window gets keyboard focus after redraw
        self.allOK = True
        self.description = str(self.plainTextEdit_description.toPlainText())

        # check user and if it needs initials, activate the text box
        if self.user in self.users_with_initals:
            self.lineEdit_initials.setEnabled(True)
        else:
            self.lineEdit_initials.setEnabled(False)

        # check user to see if one has been selected... set login to default if it has and there is no login set
        if self.user == STARTING_USER_LIST_TEXT:
            self.pushButton_login.setEnabled(False)
        else:
            self.pushButton_login.setEnabled(True)
            if not self.login_status:
                self.pushButton_login.setDefault(True)

        # check to see if logged in - if not, disable everything below login
        if self.login_status:
            self.label_password.setText("** Logged In **")
            self.pushButton_login.setEnabled(False)
            self.comboBox_artistSelect.setEnabled(False)
        else:
            self.label_password.setText("Shotgun Password")
            self.pushButton_login.setEnabled(True)

        # check the submit checkbox and enable fields if set
        if self.checkBox_forReview.isChecked():
            self.lineEdit_forReview.setEnabled(True)
            self.pushButton_getForReview.setEnabled(True)
            self.submit_movie=True

        # check for movie submit check-box
        if self.submit_movie:
            self.lineEdit_forReview.setEnabled(True)
            self.pushButton_getForReview.setEnabled(True)
        else:
            self.lineEdit_forReview.setEnabled(False)
            self.pushButton_getForReview.setEnabled(False)

        # check for a need for initals
        if self.user in INITIALS_LIST:
            self.label_initials.setText('Add Your Initials')
            self.lineEdit_initials.show()
        else:
            self.label_initials.setText('')
            self.lineEdit_initials.hide()
            self.user_initials = ''
            self.lineEdit_initials.setText('')

        # check to see if the version file is a movie and, if so and the movie line is empty, fill that in
        if self.version_file_path and os.path.splitext(str(self.version_file_path).lower())[1] in MOVIE_FILE_EXTENSION_LIST and not self.movie_file_path:
            self.movie_file_path = str(self.version_file_path)
            self.lineEdit_forReview.setText(self.movie_file_path)

        # check for conditions that allow an update to happen
        conditions = True # start by assuming we can go and switch if we can't
        if self.user in INITIALS_LIST and not self.user_initials:
            conditions = False
        if conditions and not self.login_status:
            conditions = False
        if conditions and self.version_file_path and not os.path.exists(self.version_file_path):
            conditions = False
        if conditions and self.submit_movie:
            if self.movie_file_path and not os.path.exists(self.movie_file_path):
                conditions = False
            if not self.movie_file_path:
                conditions = False

        #enable the submit button if appropriate
        if conditions:
            self.pushButton_submit.setEnabled(True)
            self.pushButton_submit.setDefault(True)
        else:
            self.pushButton_submit.setEnabled(False)


    # self.pushButton_login
    @pyqtSignature("") 
    def on_pushButton_login_clicked(self):
        result = self.sgu.authenticate_human_user(self.user_name, self.lineEdit_password.text())
        if result:
            self.login_status = True
        else:
            # user tried to log in and failed - let them know
            QMessageBox.about(self, "Log In Error", "Unable to login to Shotgun using your user/pass combination, please try again")
        self.updateUI()

    # self.pushButton_getVersionFile
    @pyqtSignature("")
    def on_pushButton_getVersionFile_clicked(self):
        self.version_file_path = str(QFileDialog.getOpenFileName(self, "Select the file to submit as a Version"   ))
        if self.version_file_path:
            self.lineEdit_versionFile.setText(self.version_file_path)
        self.updateUI()

    # self.pushButton_getForReview
    @pyqtSignature("") 
    def on_pushButton_getForReview_clicked(self):
        self.movie_file_path = str(QFileDialog.getOpenFileNameAndFilter(self, "Select a movie file to submit for screening",
                                   filter= "Movies ( *.mp4 *.mov)")[0]) # the getopenfile returns a tuple of length 2
        if self.movie_file_path:
            self.lineEdit_forReview.setText(self.movie_file_path)
        self.updateUI()

    # self.pushButton_quit
    @pyqtSignature("")
    def on_pushButton_quit_clicked(self):
        QApplication.quit()

    # self.checkBox_forReview
    @pyqtSignature("bool")
    def on_checkBox_forReview_clicked(self):
        #lcheckBox_forReview boolean toggle code here
        self.submit_movie = self.checkBox_forReview.isChecked()
        self.updateUI()

    # self.comboBox_artistSelect
    @pyqtSignature("QString")
    def on_comboBox_artistSelect_currentIndexChanged(self):
        if self.user:
            self.user = self.comboBox_artistSelect.currentText()
            self.user_name = [ user[1] for user in self.user_list if user[0] == self.user][0]
            self.user_id = [ user[2] for user in self.user_list if user[0] == self.user][0]
        self.updateUI()

    # self.comboBox_version_type
    @pyqtSignature("QString")
    def on_comboBox_version_type_currentIndexChanged(self):
        self.version_type = str(self.comboBox_version_type.currentText())
        self.updateUI()

    # self.lineEdit_forReview
    @pyqtSignature("QString")
    def on_lineEdit_forReview_textEdited(self):
        self.movie_file_path = str(self.lineEdit_forReview.text())
        self.emit(SIGNAL("update"))

    # self.lineEdit_initials
    @pyqtSignature("QString")
    def on_lineEdit_initials_textEdited(self):
        self.user_initials = str(self.lineEdit_initials.text())
        self.updateUI()

    # self.lineEdit_versionFile
    @pyqtSignature("QString")
    def on_lineEdit_versionFile_textEdited(self):
        self.version_file_path = str(self.lineEdit_versionFile.text())
        self.updateUI()

    # self.lineEdit_versionFile
    @pyqtSignature("QString")
    def on_lineEdit_versionFile_textChanged(self):
        self.version_file_path = str(self.lineEdit_versionFile.text())
        self.updateUI()

    # self.plainTextEdit_description
    @pyqtSignature("")
    def on_plainTextEdit_description_textEdited(self):
        self.updateUI()

    # self.pushButton_submit   
    @pyqtSignature("")
    def on_pushButton_submit_clicked(self):
        if not self.submit_call_track:
            self.submit_call_track = True
            return
        else:
            self.submit_call_track = False

        sgerrmsg = "There were no matching {0}s, make sure that you have selected the right kind of entity and try again"
        if not self.allOK:
            return
        try:
            self.created_version_id = update_shotgun(self.sg, self.version_file_path, self.description, self.user_id, self.version_type, self.user_initials, self )
            if not self.created_version_id: # sg did not find anything! Tell the user and let them try again or quit
                self.allOK = False
                sub_dialog = dMFXsubmitterSubDialog(
                    "No Matches", "Reset", "QUIT!", sgerrmsg.format(self.version_type), boxeditable = False, parent=self )
                button, text, pick = sub_dialog.getValues()
                if sub_dialog.exec_():
                    sub_dialog.close()
                    button, text, pick = sub_dialog.getValues()
                    if button == 'No' :
                        QApplication.quit()
                    else:
                        return # return if they click on Retry
                else: return # return if they close the window

            mainlabel = "Success!"
            yeslabel = 'Go Again'
            nolabel = 'QUIT!'
            boxtext =  'Your version was successfully created'

            if self.allOK and self.submit_movie:
                if not do_submit_for_review(self.sg,self.movie_file_path,self.created_version_id):
                    # the sym-link failed for some reason after 2 tries...
                    mainlabel = "Partial Success..."
                    boxtext = "Your version was created but the movie was NOT put into today's Review Folder. Please add it manually, or resubmit the Version"

        except Exception,e:
            mainlabel = "ERROR!"
            yeslabel = 'Reset'
            nolabel = 'QUIT!'
            boxtext =  'Something Went Horribly Wrong! -\nError: {0}\n{1}'.format(e,traceback.format_exc())

        #QMessageBox.about(self, "updateUI", output_string)
        sub_dialog = dMFXsubmitterSubDialog(mainlabel,yeslabel,nolabel, boxtext )
        if sub_dialog.exec_():
            sub_dialog.close()
            button, text, pick = sub_dialog.getValues()
            if button == 'No' :
                QApplication.quit()
            else:
                self.reset_to_go_again()