Esempio n. 1
0
    def getConvergence(self):
        """
        Looks for dragon take.xml file, and returns stereoConvR value.
        Reimplement in client forks based on workflow.
        """
        default = config.RV_STEREO_OFFSET
        if not self.seq_right:
            return default

        top = os.path.dirname(self.seq_right.path())
        done = False
        count = 0

        def _getStereoConvR(path):
            f = open(os.path.realpath(path), 'r')
            m = re.search(r'stereoConvR="(\d+.\d+)"', f.read())
            if m:
                return m.groups()[0]
            f.close()

        while not done:
            path = os.path.join(top, 'take.xml')
            if os.path.isfile(path):
                try:
                    return _getStereoConvR(path)
                except Exception, e:
                    log.debug(str(e))
                    return default
                done = True
            elif top != os.path.dirname(top):
                top = os.path.dirname(top)
Esempio n. 2
0
 def getShots(self, show):
     log.debug('getShots: %s' % show)
     self._shotsThread = ShotgunShotsThread(self, self.shows.get(show))
     self.connect(self._shotsThread, QtCore.SIGNAL("shots (PyQt_PyObject)"), self.updateCompleter)
     self.connect(self._shotsThread, QtCore.SIGNAL("error (PyQt_PyObject)"), self.handleShotsError)
     self._shotsThread.start()
     self.threads_queue.put(self._shotsThread)
Esempio n. 3
0
 def getShows(self):
     log.debug('getShows')
     self._showsThread = ShotgunShowsThread(self)
     self.connect(self._showsThread, QtCore.SIGNAL("shows (PyQt_PyObject)"), self.handleShows)
     self.connect(self._showsThread, QtCore.SIGNAL("error (PyQt_PyObject)"), self.handleShowsError)
     self._showsThread.start()
     self.threads_queue.put(self._showsThread)
Esempio n. 4
0
 def handleLoad(self, version):
     log.debug('handleLoad: %s' % version.left)
     self.version = version
     if not version.left or not os.path.isfile(version.left):
         log.info('File not found: %s' % version.left)
         self.stop()
     self.load(Phonon.MediaSource(version.left))
     self.main.emit(QtCore.SIGNAL('totalTime (PyQt_PyObject)'), self.totalTime())
Esempio n. 5
0
    def handleThreadComplete(self, path):
        """
        Thread completion handler.
        """
        log.debug('handleThreadComplete: %s' % path)
        all_done = True
        left_done = True
        right_done = True

        for thread in self.threads:

            # skip running threads
            if thread.isAlive():
                all_done = False
                if thread.eye == 'left':
                    left_done = False
                elif thread.eye == 'right':
                    right_done = False
                continue

            # update left eye movie path
            elif thread.eye == 'left' and thread.name == 'movie':
                params = {config.SG_FIELD_MAP.get('MOVIE_LEFT'): path}
                log.debug('update left: %s' % params)
                updateEntity(self.sg_version_dict, params)

            # update right eye movie path
            elif thread.eye == 'right' and thread.name == 'movie':
                params = {config.SG_FIELD_MAP.get('MOVIE_RIGHT'): path}
                log.debug('update right: %s' % params)
                updateEntity(self.sg_version_dict, params)

            # update left eye frames path
            elif thread.eye == 'left' and thread.name == 'frames':
                params = {config.SG_FIELD_MAP.get('FRAMES_LEFT'): path}
                log.debug('update left: %s' % params)
                updateEntity(self.sg_version_dict, params)

            # update right eye frames path
            elif thread.eye == 'right' and thread.name == 'frames':
                params = {config.SG_FIELD_MAP.get('FRAMES_RIGHT'): path}
                log.debug('update right: %s' % params)
                updateEntity(self.sg_version_dict, params)

            # remove completed threads from queue
            self.threads.remove(thread)

        if left_done:
            self.toggleLeftProgress(False)

        if right_done:
            self.toggleRightProgress(False)

        if all_done:
            self.btnSubmit.setEnabled(True)
            self.btnFindLeft.setEnabled(True)
            self.btnFindRight.setEnabled(True)
Esempio n. 6
0
 def handleFind(self, show=None, shot=None, task=None):
     log.debug('handleFind: %s %s %s' %(show, shot, task))
     if show is None:
         show = str(self.showCombo.currentText().toAscii())
     if shot is None:
         shot = str(self.editSearch.text().toAscii())
     if not shot:
         self.main.emit(QtCore.SIGNAL('showQueue ()'), )
     else:
         self.main.emit(QtCore.SIGNAL('findVersions (PyQt_PyObject)'), self.shots.get(shot))
Esempio n. 7
0
 def clear(self):
     _remove = []
     for item in self.versionsTree:
         if not self.inQueue(item):
             log.debug('removing %s' % item)
             _remove.append(item)
         else:
             log.debug('hiding %s' % item)
             item.setHidden(True)
     for item in _remove:
         self.versionsTree.removeItem(item)
Esempio n. 8
0
 def handleThreadStart(self, data):
     """
     thread start handler
     """
     name, eye = data
     log.debug('handleThreadStart: %s %s' % (name, eye))
     self.btnSubmit.setEnabled(False)
     self.btnFindLeft.setEnabled(False)
     self.btnFindRight.setEnabled(False)
     if eye == 'left':
         self.toggleLeftProgress(True)
     elif eye == 'right':
         self.toggleRightProgress(True)
Esempio n. 9
0
def makeThumb(source, frame=2, res=256):
    """
    Creates png thumbnail from the source.

    :param source: rvio source input (movie, sequence)
    :param frame: frame to create thumbnail from
    :param res: thumbnail width in pixels

    :return: thumbnail path
    """
    import tempfile
    thumb = tempfile.mkstemp(prefix='thb', suffix='.png')[1]
    cmd = "%s %s -resize %d -t %d -o %s" % (config.RV_RVIO_PATH, source, res, frame, thumb)
    log.debug('makeThumb: %s' % cmd)
    os.system(cmd)
    return thumb
Esempio n. 10
0
    def addThread(self, klass, seq, params):
        """
        create and start a new thread

        :param klass: threads.py thread classs
        :param seq: file sequence arg to pass to thread
        :param params: params dict to pass to thread
        """
        log.debug('addThread: %s %s %s' % (klass, seq, params))
        if not klass or not seq:
            return
        thread = klass(self, seq, params)
        self.connect(thread, QtCore.SIGNAL('start (PyQt_PyObject)'), self.handleThreadStart)
        self.connect(thread, QtCore.SIGNAL('complete (PyQt_PyObject)'), self.handleThreadComplete)
        self.connect(thread, QtCore.SIGNAL('error (PyQt_PyObject)'), self.handleError)
        self.threads.append(thread)
        thread.start()
        return thread
Esempio n. 11
0
    def handleChangeShow(self, show=None):
        log.debug('handleChangeShow: %s' % show)
        if show is None:
            show = str(self.showCombo.currentText().toAscii())
        if not show:
            return

        idx = self.showCombo.findText(show)

        if not idx:
            for _show in self.shows.values():
                if show == _show.get(config.SG_FIELD_MAP.get('SHOWNAME')):
                    show = _show.get(config.SG_FIELD_MAP.get('SHOW'))
                    idx = self.showCombo.findText(show)

        if idx >= 0 and idx != self.showCombo.currentIndex():
            self.showCombo.setCurrentIndex(idx)

        self.getShots(str(show))
Esempio n. 12
0
def makeDaily(frames, **kwargs):
    log.debug('makeDaily: %s' % kwargs)
    return makeMov(frames, **kwargs)
Esempio n. 13
0
def makeAvid(frames, **kwargs):
    log.debug('makeAvid: %s' % kwargs)
    return makeMov(frames, **kwargs)
Esempio n. 14
0
 def showQueue(self):
     log.debug('showQueue')
     self.clear()
     for version in self.queue():
         version.setHidden(False)
Esempio n. 15
0
 def removeFromQueue(self, version):
     if self.inQueue(version):
         log.debug('removing from queue: %s' % version)
         del self.queue()[self.queue().index(version)]
         self.emit(QtCore.SIGNAL('versionRemovedFromQueue (PyQt_PyObject)'), version)
Esempio n. 16
0
def makeMov(frames, **kwargs):
    """
    Makes a movie file from a frame sequence.

    :param sequences: rvio-compatible file sequence string

    :param kwargs: Supported kwargs

        show         shotgun show name
        shot         shotgun shot code
        task         shotgun task name
        version      version or pts number*
        width        width of mov to resize [0 (same as input)]
        quality      compression quality 0 to 1.0 [0.95]
        outfile      output movie file path
        dailies      submit this movie to shotgun (bool)*
        comment      slate comment and take description
        frameBurn    burn frame numbers into frames (bool)

    * If dailies is true, all kwargs get passed to makeTake.
    * If version is None, a version number will be auto generated.

    :return: path to generated movie file
    """
    _in = frames
    _out = kwargs.get('outfile', config.DAILIES_MOVIE_PATH % kwargs)

    # slate settings
    _show = kwargs.get('show', None)
    _shot = kwargs.get('shot', None)
    _task = kwargs.get('task', None)
    _slate = kwargs.get('slate', False)
    _user = kwargs.get('user', os.environ.get('USER'))
    _date = time.strftime('%a %b %e, %Y %l:%M%P')
    _comment = kwargs.get('comment', '')

    # rvio settings
    _width = kwargs.get('width', config.RV_WIDTH)
    _height = kwargs.get('height', None)
    _crop = kwargs.get('crop', None)
    _resize = kwargs.get('resize', None)
    _quality = kwargs.get('quality', config.RV_QUALITY)
    _frameBurn = kwargs.get('frameBurn', False)
    _dryRun = kwargs.get('dryRun', False)

    # rvio options strings
    perSeqOpts = []
    optionStrings = config.RV_RVIO_OPT[:]

    # scale / resize / crop
    if _height:
        optionStrings.append('-outres %d %d' %(_width, _height))
    else:
        optionStrings.append('-resize %d' % _width)

    if _resize and type(_resize) in (list, tuple):
        optionStrings.append('-resize "%d %d"' %(_resize[0], _resize[1]))

    if _crop and type(_crop) in (list, tuple):
        perSeqOpts.append('-crop %d %d %d %d' %(_crop[0], _crop[1], _crop[2], _crop[3]))

    # quality
    optionStrings.append('-quality %s' % _quality)
    optionStrings.append('-v')

    # rvio slate options
    if _slate:
        slateArgs = ['-leader', 'simpleslate', config.RV_SLATE_TITLE, ]
        slateArgs.append('"Show=%s"' % _show)
        slateArgs.append('"Shot=%s"' % _shot)
        slateArgs.append('"Task=%s"' % _task)
        slateArgs.append('"Date=%s"' % _date)
        slateArgs.append('"User=%s"' % _user)
        slateArgs.append('"Source=%s"' % _in)
        slateArgs.append('"Comments=%s"' % _comment)
        optionStrings.extend(slateArgs)

        if _frameBurn:
            optionStrings.extend(['-overlay', 'frameburn', '0.5', '0.5', '20.0', ])

    # the command string
    cmd = "%s [ %s %s ] %s -o %s" % (config.RV_RVIO_PATH, _in, ' '.join(perSeqOpts), ' '.join(optionStrings), _out)
    log.debug('cmd: %s' % cmd)

    # check to make sure base dir exists
    _basedir = os.path.dirname(_out)
    if not os.path.isdir(_basedir):
        try:
            os.makedirs(_basedir)
        except EnvironmentError, e:
            log.error(traceback.format_exc())
            if not os.path.exists(_basedir):
                return
Esempio n. 17
0
def makeTake(show, shot, **kwargs):
    """
    Creates the Version/Dailies entity in Shotgun.

    :param show: Project short name (sg_short_name)
    :param shot: Shot code (code)
    :param kwargs: Valid kwargs are

        name: Name of the take, must be unique
        comment: Dailies comments
        version: Dailies take, pts or version number
        leftMoviePath: Left-eye (or mono) movie file path
        leftFramesPath: Left-eye (or mono) frames file path
        rightMoviePath: Right-eye movie file path
        rightFramesPath: Right-eye frames file path

    :return: Shotgun entity dict
    :raise: shotgun.Fault
    """

    try:
        from shotgun import Shotgun
        sg = Shotgun(config.SG_SCRIPT_URL, config.SG_SCRIPT_NAME, config.SG_SCRIPT_KEY)
    except ImportError:
        raise Exception('error importing shotgun api')

    log.debug('makeTake: %s' % kwargs)

    # get show and shot from shotgun
    _show = getShows(show)[0]
    _shot = getShots(show, shot)[0]
    _task = None

    # look for task
    results = getTasks(_shot, kwargs.get('task'))
    if results:
        _task = results[0]

    # take version number
    version = kwargs.get('version')
    if not version:
        version = len(getVersions(_shot, _task)) + 1
        kwargs.update(version=version)

    # take name
    _name = {
        'show': show,
        'shot': shot,
        'sequence': shot.split('_')[0],
        'task': kwargs.get('task', ''),
        'version': version,
        'eye': kwargs.get('eye', ''),
    }
    name = kwargs.get('name', config.DAILIES_TAKE_NAME % _name)

    # basic required fields
    params = {
        'entity': _shot,
        'project': _show,
        config.SG_FIELD_MAP.get('NAME'): name,
        config.SG_FIELD_MAP.get('COMMENT'): kwargs.get('comment', ''),
        config.SG_FIELD_MAP.get('TAKE_NUMBER'): str(version),
    }

    # shotgun task
    if _task:
        params.update(**{'sg_task': _task})

    # file paths
    leftMoviePath = kwargs.get('leftMoviePath')
    leftFramesPath = kwargs.get('leftFramesPath')
    rightMoviePath = kwargs.get('rightMoviePath')
    rightFramesPath = kwargs.get('rightFramesPath')

    # link to left-eye movie/frames
    if leftMoviePath:
        params.update(**{config.SG_FIELD_MAP.get('MOVIE_LEFT'): leftMoviePath})
    if leftFramesPath:
        params.update(**{config.SG_FIELD_MAP.get('FRAMES_LEFT'): leftFramesPath})

    # link to right-eye movie/frames
    if rightMoviePath:
        params.update(**{config.SG_FIELD_MAP.get('MOVIE_RIGHT'): rightMoviePath})
    if rightFramesPath:
        params.update(**{config.SG_FIELD_MAP.get('FRAMES_RIGHT'): rightFramesPath})

    sg_take = sg.create('Version', params)

    return sg_take
Esempio n. 18
0
 def addToQueue(self, version):
     if not self.inQueue(version):
         log.debug('adding to queue: %s' % version)
         self.queue().append(version)
         self.emit(QtCore.SIGNAL('versionAddedtoQueue (PyQt_PyObject)'), version)