Ejemplo n.º 1
0
def setCurrentTask(projectId, taskId):
    #if taskId == currentTask().m_id : return
    ''' scene changed : open confirm dialog '''
    if mut.isSceneChanged():
        if not mut.confirmDialog('Warning: Scene Not Saved',
                                 'Scene changes not saved, continue ?'):
            return

    lnk = ndb.link()
    task = ndb.taskInfo(projectId, taskId, lnk)
    if not task.m_id: return
    ''' create (or set) project '''
    mut.createProject(projectFolder(task))
    ''' task not started : update task & create new scene, else open scene '''
    if not task.m_state:
        task.m_state = ndb.TASKSTATE_STARTED
        task.m_v = 1

        mut.newScene()
        mut.saveScene(taskPath(task))

    else:
        mut.openScene(taskPath(task))
    ''' store task '''
    task.store(lnk)
    currentTask_set(task)
Ejemplo n.º 2
0
def incrementCurrentTask():
    task = currentTask()
    if not task.m_id: return
    ''' update task '''
    task.m_state = max(currentTask().m_state, ndb.TASKSTATE_STARTED)
    task.m_v += 1
    ''' save scene '''
    mut.saveScene(taskPath(task))
    ''' store task '''
    lnk = ndb.link()
    task.store(lnk)
    currentTask_set(task)
Ejemplo n.º 3
0
    def loadRows(self, project_id, task_id=0):
        if not project_id:
            self.clearRows()
            return

        lnk = ndb.link()
        ''' 0: name, 1: type, 2: create time '''
        query = "\
        SELECT pbl.m_name, pbl.m_type, pbl.m_create_time\
        FROM tbl_publish{} pbl\
            INNER JOIN tbl_task{} tsk ON tsk.m_id= pbl.m_task_id".format(
            project_id, project_id)

        if task_id: query += " WHERE tsk.m_id= {}".format(task_id)

        result = lnk.execute(query)
        self.m_rows = result.fetchall()

        self.update()
Ejemplo n.º 4
0
    def loadRows(self, project_id, job_id=0, task_type=-1):
        if not project_id:
            self.clearRows()
            return

        lnk = ndb.link()

        query = "\
        SELECT pbl.m_id, pbl.m_name, pbl.m_type, tsk.m_type, job.m_name\
        FROM tbl_publish{} pbl\
            INNER JOIN tbl_task{} tsk ON tsk.m_id= pbl.m_task_id\
            INNER JOIN tbl_job{} job ON job.m_id= tsk.m_job_id".format(
            project_id, project_id, project_id)

        if job_id: query += " WHERE job.m_id= {}".format(job_id)
        if task_type >= 0: query += " AND tsk.m_type= {}".format(task_type)

        result = lnk.execute(query)
        self.m_rows = result.fetchall()

        self.update()
Ejemplo n.º 5
0
    def validate(self):
        if not self.isVisible(): return

        self.m_showMyTasksCB.blockSignals(True)
        self.m_projectList.selectionModel().blockSignals(True)
        self.m_jobList.selectionModel().blockSignals(True)
        self.m_taskList.selectionModel().blockSignals(True)

        lnk = ndb.link()

        if self.m_showMyTasks: userId = ndb.user_id()
        else: userId = 0
        ''' validate m_setShowEveryTasksCB '''
        if not self.m_showMyTasks_valid:
            print("validating m_showMyTasks")
            self.m_showMyTasks_valid = True
            self.m_showMyTasksCB.setChecked(self.m_showMyTasks)
        ''' validate m_projectList '''
        if not self.m_projectList_valid:
            print("validating m_projectList")
            self.m_projectList_valid = True
            self.m_projectList.loadRows(lnk)

            idx = ndb.rows_valueIndex(
                self.m_projectList.m_rows, 0,
                self.m_projectId)  # compute m_projectId index in m_projectList
            if idx < 0:  # if index < 0 : m_projectId= 1st project id (or 0 if no preoject)
                idx = 0
                if len(self.m_projectList.m_rows):
                    self.m_projectId = self.m_projectList.m_rows[0][0]
                else:
                    self.m_projectId = 0

            if self.m_projectId:
                self.m_projectList.selectionModel().select(
                    self.m_projectList.model().index(idx, 0),
                    core.QItemSelectionModel.Select)
        ''' validate m_jobList '''
        if not self.m_jobList_valid:
            print("validating m_jobList")
            self.m_jobList_valid = True
            self.m_jobList.loadRows(lnk, self.m_projectId, userId)

            idx = ndb.rows_valueIndex(
                self.m_jobList.m_rows, 0,
                self.m_jobId)  # compute m_jobId index in m_jobList
            if idx < 0: self.m_jobId = 0  # if index < 0 : m_jobId= 0

            self.m_jobList.selectionModel().select(
                self.m_jobList.model().index(idx + 1, 0),
                core.QItemSelectionModel.Select)
        ''' validate m_taskList '''
        if not self.m_taskList_valid:
            print("validating m_taskList")
            self.m_taskList_valid = True
            self.m_taskList.loadRows(lnk, self.m_projectId, self.m_jobId,
                                     userId)

        self.m_showMyTasksCB.blockSignals(False)
        self.m_projectList.selectionModel().blockSignals(False)
        self.m_jobList.selectionModel().blockSignals(False)
        self.m_taskList.selectionModel().blockSignals(False)
Ejemplo n.º 6
0
    def validate(self):
        if not self.isVisible(): return

        lnk = ndb.link()
        ''' projects '''
        if not self.m_projects_valid:
            self.m_projects_valid = True
            ''' project rows '''
            self.m_projects = ndb.projectList(lnk)
            idx = ndb.rows_valueIndex(
                self.m_projects, 0,
                self.m_projectId)  # compute m_jobId index in m_jobs
            if idx < 0:  # if idx < 0 : m_projectId= 1st project id (or 0 if no preoject)
                if len(self.m_projects):
                    self.m_projectId = self.m_projects[0][0]
                else:
                    self.m_projectId = 0
            ''' build menu '''
            self.m_projectsM.blockSignals(True)
            self.m_projectsM.clear()
            for i in range(0, len(self.m_projects)):
                self.m_projectsM.addItem(
                    self.m_projects[i][1])  # add item to menu
            if idx > 0: self.m_projectsM.setCurrentIndex(idx)
            self.m_projectsM.blockSignals(False)
        ''' jobs '''
        if not self.m_jobs_valid:
            self.m_jobs_valid = True
            ''' job rows '''
            self.m_jobs = ndb.jobList(lnk, self.m_projectId)
            idx = ndb.rows_valueIndex(
                self.m_jobs, 0,
                self.m_jobId)  # compute m_jobId index in m_jobs
            if idx < 0: self.m_jobId = 0  # if index < 0 : m_jobId= 0
            ''' build menu '''
            self.m_jobsM.blockSignals(True)
            self.m_jobsM.clear()
            self.m_jobsM.addItem("Any")
            for i in range(0, len(self.m_jobs)):
                self.m_jobsM.addItem(self.m_jobs[i][1])  # add item to menu
            if idx >= 0: self.m_jobsM.setCurrentIndex(idx + 1)
            self.m_jobsM.blockSignals(False)
        ''' taskTypes '''
        if not self.m_taskTypes_valid:
            self.m_taskTypes_valid = True
            ''' taskType rows '''
            self.m_taskTypes = ndb.taskTypeList(lnk, self.m_projectId,
                                                self.m_jobId)
            idx = ndb.rows_valueIndex(
                self.m_taskTypes, 0,
                self.m_taskType)  # compute m_taskType index in m_jobs
            if idx < 0: self.m_taskType = -1  # if idx < 0 : m_taskType= -1
            ''' build menu '''
            self.m_taskTypesM.blockSignals(True)
            self.m_taskTypesM.clear()
            self.m_taskTypesM.addItem("Any")
            for i in range(0, len(self.m_taskTypes)):
                self.m_taskTypesM.addItem(
                    ndb.taskTypeStr(
                        self.m_taskTypes[i][0]))  # add item to menu
            if idx >= 0: self.m_taskTypesM.setCurrentIndex(idx + 1)
            self.m_taskTypesM.blockSignals(False)
        ''' table '''
        if not self.m_table_valid:
            self.m_table_valid = True

            self.m_table.loadRows(self.m_projectId, self.m_jobId,
                                  self.m_taskType)
Ejemplo n.º 7
0
def publishCurrentTask():
    task = currentTask()
    if not task.m_id: return

    lnk = ndb.link()

    info = ndb.publishInfo()

    info.load(task.m_job.m_project.m_id, "", ndb.PUBLISHTYPE_MAYA, task.m_id,
              lnk)
    info.m_task.m_v = task.m_v
    info.m_v += 1

    mut.exportMaya(publishPath(info), True)

    info.store(lnk)

    sets = listPublishSets()
    if len(sets):
        for s in sets:
            if cmds.getAttr(s + '.active'):

                cmds.select(s)

                if cmds.getAttr(s + '.exportMaya'):
                    info.load(task.m_job.m_project.m_id, s,
                              ndb.PUBLISHTYPE_MAYA, task.m_id, lnk)
                    info.m_task.m_v = task.m_v
                    info.m_v += 1

                    mut.exportMaya(publishPath(info), False)

                    info.store(lnk)

                if cmds.getAttr(s + '.exportAlembic'):
                    info.load(task.m_job.m_project.m_id, s,
                              ndb.PUBLISHTYPE_ALEMBIC, task.m_id, lnk)
                    info.m_task.m_v = task.m_v
                    info.m_v += 1

                    mut.exportAlembic(publishPath(info), False)

                    info.store(lnk)

                if cmds.getAttr(s + '.exportFBX'):
                    info.load(task.m_job.m_project.m_id, s,
                              ndb.PUBLISHTYPE_FBX, task.m_id, lnk)
                    info.m_task.m_v = task.m_v
                    info.m_v += 1

                    mut.exportFBX(publishPath(info), False)

                    info.store(lnk)

                if cmds.getAttr(s + '.exportOBJ'):
                    info.load(task.m_job.m_project.m_id, s,
                              ndb.PUBLISHTYPE_OBJ, task.m_id, lnk)
                    info.m_task.m_v = task.m_v
                    info.m_v += 1

                    mut.exportOBJ(publishPath(info), False)

                    info.store(lnk)

                if cmds.getAttr(s + '.exportArchive'):
                    info.load(task.m_job.m_project.m_id, s,
                              ndb.PUBLISHTYPE_ARCHIVE, task.m_id, lnk)
                    info.m_task.m_v = task.m_v
                    info.m_v += 1

                    mut.exportArchive(publishPath(info), False)

                    info.store(lnk)
    ''' update & store task '''
    task.m_state = max(task.m_state, ndb.TASKSTATE_PUBLISHED)
    task.store(lnk)
    currentTask_set(task)