Exemplo n.º 1
0
def main(arguments=None):
    '''Set up logging and register action.'''
    if arguments is None:
        arguments = []

    parser = argparse.ArgumentParser()
    # Allow setting of logging level from arguments.
    loggingLevels = {}
    for level in (
        logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING,
        logging.ERROR, logging.CRITICAL
    ):
        loggingLevels[logging.getLevelName(level).lower()] = level

    parser.add_argument(
        '-v', '--verbosity',
        help='Set the logging output verbosity.',
        choices=loggingLevels.keys(),
        default='info'
    )
    namespace = parser.parse_args(arguments)

    '''Register action and listen for events.'''
    logging.basicConfig(level=loggingLevels[namespace.verbosity])

    ftrack.setup()
    action = AssetDelete()
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 2
0
def main(arguments=None):
    '''Set up logging and register action.'''
    if arguments is None:
        arguments = []

    parser = argparse.ArgumentParser()
    # Allow setting of logging level from arguments.
    loggingLevels = {}
    for level in (
        logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING,
        logging.ERROR, logging.CRITICAL
    ):
        loggingLevels[logging.getLevelName(level).lower()] = level

    parser.add_argument(
        '-v', '--verbosity',
        help='Set the logging output verbosity.',
        choices=loggingLevels.keys(),
        default='info'
    )
    namespace = parser.parse_args(arguments)

    '''Register action and listen for events.'''
    logging.basicConfig(level=loggingLevels[namespace.verbosity])

    ftrack.setup()
    action = Publish()
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 3
0
def main(arguments=None):
    """Set up logging and register action."""
    if arguments is None:
        arguments = []

    parser = argparse.ArgumentParser()
    # Allow setting of logging level from arguments.
    loggingLevels = {}
    for level in (
        logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING,
        logging.ERROR, logging.CRITICAL
    ):
        loggingLevels[logging.getLevelName(level).lower()] = level

    parser.add_argument(
        "-v", "--verbosity",
        help="Set the logging output verbosity.",
        choices=loggingLevels.keys(),
        default="info"
    )
    namespace = parser.parse_args(arguments)

    """Register action and listen for events."""
    logging.basicConfig(level=loggingLevels[namespace.verbosity])

    ftrack.setup()
    action = ReviewSort()
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 4
0
def main(arguments=None):
    """Set up logging and register action."""
    if arguments is None:
        arguments = []

    parser = argparse.ArgumentParser()
    # Allow setting of logging level from arguments.
    loggingLevels = {}
    for level in (logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING,
                  logging.ERROR, logging.CRITICAL):
        loggingLevels[logging.getLevelName(level).lower()] = level

    parser.add_argument("-v",
                        "--verbosity",
                        help="Set the logging output verbosity.",
                        choices=loggingLevels.keys(),
                        default="info")
    namespace = parser.parse_args(arguments)
    """Register action and listen for events."""
    logging.basicConfig(level=loggingLevels[namespace.verbosity])

    ftrack.setup()
    action = ComponentAdd()
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 5
0
    def constructWidget(self):
        '''Return widget instance to test.'''
        ftrack.setup()

        users = ftrack.getUsers()
        me = users.pop()
        you = users.pop()

        self.chat = ftrack_connect.ui.widget.chat.Chat()

        history = []
        for text in ('Hi!', 'How are you?', 'Good!', 'You?', 'Great!',
                     'Thanks!'):
            sender, receiver = random.choice([(me, you), (you, me)])
            history.append(
                dict(text=text,
                     receiver=receiver.getId(),
                     sender=dict(id=sender.getId(), name=sender.getName()),
                     date=str(datetime.datetime.utcnow()),
                     id=str(uuid.uuid1()),
                     me=(sender == me)))

        self.chat.load(history)

        return self.chat
Exemplo n.º 6
0
def main():
    '''Register action and listen for events.'''
    logging.basicConfig(level=logging.INFO)

    ftrack.setup()
    action = Timelogs()
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 7
0
    def constructWidget(self):
        '''Return widget instance to test.'''
        ftrack.setup()

        self.eventHubThread = ftrack_connect.event_hub_thread.EventHubThread()
        self.eventHubThread.start()

        self.users = [
            user for user in ftrack.getUsers()
            if (user.get('username') != getpass.getuser())
        ]
        self.groups = ('Assigned', 'Related', 'Contributors', 'Others')

        widget = QtGui.QWidget()
        widget.setLayout(QtGui.QVBoxLayout())
        widget.setMinimumSize(QtCore.QSize(600, 600))
        user = ftrack.getUser(getpass.getuser())

        self.crewHub = MyCrewHub()
        self.crew = ftrack_connect.ui.widget.crew.Crew(self.groups,
                                                       user,
                                                       hub=self.crewHub)
        widget.layout().addWidget(self.crew)

        userIds = []
        for user in self.users:
            userIds.append(user.getId())
            self.crew.addUser(user.getName(), user.getId())

        user = ftrack.getUser(getpass.getuser())
        self.crewHub.populateUnreadConversations(user.getId(), userIds)

        data = {
            'user': {
                'name': user.getName(),
                'id': user.getId()
            },
            'application': {
                'identifier': 'ftrack',
                'label': 'ftrack'
            },
            'context': {
                'project_id': 'my_project_id',
                'containers': []
            }
        }

        self.crewHub.enter(data)

        widget.activateWindow()
        widget.show()
        widget.raise_()

        ftrack_connect.ui.theme.applyTheme(widget, 'integration')
        return widget
Exemplo n.º 8
0
    def api(self):
        try:
            import ftrack
        except ImportError:
            raise Exception('ftrack legacy api not found in PYTHONPATH.')

        try:
            ftrack.setup()
        except Exception as error:
            self.logger.debug(error)
            # Initialize ftrack legacy api to register locations,
            # ignore hub Exceptions.
            pass

        self._api = ftrack
        self.logger.debug('Ftrack legacy python API successfully loaded.')
        return self._api
Exemplo n.º 9
0
def main(arguments=None):
    '''Set up logging and register action.'''
    if arguments is None:
        arguments = []

    parser = argparse.ArgumentParser()
    # Allow setting of logging level from arguments.
    loggingLevels = {}
    for level in (
        logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING,
        logging.ERROR, logging.CRITICAL
    ):
        loggingLevels[logging.getLevelName(level).lower()] = level

    parser.add_argument(
        '-v', '--verbosity',
        help='Set the logging output verbosity.',
        choices=loggingLevels.keys(),
        default='info'
    )
    namespace = parser.parse_args(arguments)

    '''Register action and listen for events.'''
    logging.basicConfig(level=loggingLevels[namespace.verbosity])

    ftrack.setup()

    # Create store containing applications.
    application_store = ApplicationStore()

    path = os.path.join(ftrack_connect_path, 'resource',
                        'ftrack_connect_nuke')
    pluginpath = os.environ.get('FTRACK_CONNECT_NUKE_PLUGINS_PATH', path)
    launcher = ApplicationLauncher(application_store,
                                   plugin_path=pluginpath)

    # Create action and register to respond to discover and launch actions.
    action = LaunchApplicationAction(application_store, launcher)
    action.register()

    ftrack.EVENT_HUB.wait()
Exemplo n.º 10
0
    def configureConnectAndDiscoverPlugins(self):
        '''Configure connect and load plugins.'''

        # Local import to avoid connection errors.
        import ftrack
        ftrack.EVENT_HANDLERS.paths.extend(self.pluginHookPaths)
        ftrack.LOCATION_PLUGINS.paths.extend(self.pluginHookPaths)

        ftrack.setup()
        self.tabPanel = _tab_widget.TabWidget()
        self.tabPanel.tabBar().setObjectName('application-tab-bar')
        self.setCentralWidget(self.tabPanel)

        self._discoverTabPlugins()

        ftrack.EVENT_HUB.subscribe(
            'topic=ftrack.connect and source.user.username={0}'.format(
                getpass.getuser()
            ),
            self._relayEventHubEvent
        )
        self.eventHubSignal.connect(self._onConnectTopicEvent)

        self.eventHubThread = _event_hub_thread.EventHubThread()
        self.eventHubThread.start()

        self.focus()

        # Listen to discover connect event and respond to let the sender know
        # that connect is running.
        ftrack.EVENT_HUB.subscribe(
            'topic=ftrack.connect.discover and source.user.username={0}'.format(
                getpass.getuser()
            ),
            lambda event : True
        )
                task = version.getTask()
            except:
                return

            # task_status = utils.GetStatusByName(version_status.get('name').lower())

            # Filter to versions with status change to "render complete"
            if version_status.get('name').lower() == 'not ':
                pass

            # Proceed if the task status was set
            if task_status:
                # Get path to task
                path = task.get('name')
                for p in task.getParents():
                    path = p.get('name') + '/' + path

                # Setting task status
                try:
                    task.setStatus(task_status)
                except Exception as e:
                    print '%s status couldnt be set: %s' % (path, e)
                else:
                    print '%s updated to "%s"' % (path, task_status.get('name'))


# Subscribe to events with the update topic.
ftrack.setup()
ftrack.EVENT_HUB.subscribe('topic=ftrack.update', callback)
ftrack.EVENT_HUB.wait()
                    if sys.platform == 'win32':
                        rootFolder = disk.get('windows')
                    elif sys.platform == 'linux2':
                        rootFolder = disk.get('unix')
                    projFolder = os.path.join(rootFolder, project.getName())
                makeDirs(projFolder)
                templateFolder = os.path.join(projFolder, 'template_files')
                copy_tree(TEMPLATE_FILES, templateFolder)


def makeDirs(projDir):
    try:
        jd = open(FOLDER_STRUCT).read()
        data = json.loads(jd)
        for key in data:
            folder = os.path.join(projDir, key)
            if not os.path.exists(folder):
                os.makedirs(folder)
            for each in data[key]:
                subFolder = os.path.join(folder, each)
                if not os.path.exists(subFolder):
                    os.makedirs(subFolder)
    except:
        print "Could not find " + FOLDER_STRUCT
        print "No directories created"

# Subscribe to events with the update topic.
ftrack.setup()
ftrack.EVENT_HUB.subscribe('topic=ftrack.update', callback)
ftrack.EVENT_HUB.wait()
Exemplo n.º 13
0
def CreateFTrackVersion(job, ftrackKVPs):
    #Set up the environment needed to connect to FTrack
    config = RepositoryUtils.GetEventPluginConfig("FTrack")
    ftrackURL = config.GetConfigEntryWithDefault("FTrackURL", "").strip()
    ftrackKey = config.GetConfigEntryWithDefault("FTrackAPIKey", "").strip()
    ftrackProxy = config.GetConfigEntryWithDefault("FTrackProxy", "").strip()

    username = ftrackKVPs.get("FT_Username", "")

    os.environ["FTRACK_SERVER"] = ftrackURL
    os.environ["FTRACK_APIKEY"] = ftrackKey

    if ftrackProxy:
        os.environ["FTRACK_PROXY"] = ftrackProxy

    if username:
        os.environ["LOGNAME"] = username

    #Import FTrack API
    eggPath = ftrackPath = RepositoryUtils.GetRootDirectory(
        "events/FTrack/API")
    sys.path.append(eggPath)

    import ftrack
    ftrack.setup(False)

    #TODO: Handle errors in a nicer way
    projectID = ftrackKVPs.get("FT_ProjectId", "")
    project = ftrack.Project(id=projectID)  #Fetch project with given ID

    taskID = ftrackKVPs.get("FT_TaskId", "")
    task = ftrack.Task(id=taskID)  #Fetch task with given ID

    assetID = ftrackKVPs.get("FT_AssetId", "")
    asset = ftrack.Asset(id=assetID)  #Fetch asset with given ID

    description = ftrackKVPs.get("FT_Description", "")
    version = asset.createVersion(comment=description, taskid=taskID)

    #Set version status based on the Deadline Job's status
    dlStatus = job.Status
    ftStatusName = ""
    if dlStatus == JobStatus.Active:
        if job.RenderingChunks > 0:
            ftStatusName = config.GetConfigEntryWithDefault(
                "VersionStatusStarted", "").strip()
        else:
            ftStatusName = config.GetConfigEntryWithDefault(
                "VersionStatusQueued", "").strip()
    elif dlStatus == JobStatus.Failed:
        ftStatusName = config.GetConfigEntryWithDefault(
            "VersionStatusFailed", "").strip()
    elif dlStatus == JobStatus.Completed:
        ftStatusName = config.GetConfigEntryWithDefault(
            "VersionStatusFinished", "").strip()

        #Set the components based on the Job's output (if available)
        for i in range(len(job.OutputDirectories)):
            outPath = os.path.normpath(job.OutputDirectories[i])
            outPath = RepositoryUtils.CheckPathMapping(outPath, True)

            if i < len(job.OutputFileNames):
                outPath = os.path.join(outPath, job.OutputFileNames[i])

                #Change out our '#' padding for python-style padding, which FTrack expects
                match = re.search("#+", outPath)
                if match:
                    padding = match.group(0)
                    outPath = "{0} [{1}]".format(
                        outPath.replace(padding, "%%0%dd" % len(padding)),
                        job.FramesList)

            ClientUtils.LogText(
                "Creating Component for Deadline output '{0}'...".format(
                    outPath))
            try:
                #Job's complete, so output should be present now, let FTrack pick a location for us
                version.createComponent(name=("Deadline_Output_%d" % i),
                                        path=outPath)
            except:
                #That failed =/
                ClientUtils.LogText(traceback.format_exc())
                ClientUtils.LogText(
                    "Failed to create component for output '%s'. No component will be created."
                    % outPath)

        ClientUtils.LogText("Done creating Components.")

    if ftStatusName:
        statuses = project.getVersionStatuses()

        ftStatus = None
        for status in statuses:
            if status.getName().lower() == ftStatusName.lower():
                ftStatus = status
                break

        if ftStatus == None:
            ClientUtils.LogText(
                "Could not find valid Asset Version Status with name '%s'.  The Version Status might not be set properly."
                % ftStatusName)
        else:
            ClientUtils.LogText("Setting Asset Version to status '%s'." %
                                ftStatusName)
            version.setStatus(ftStatus)

    version.publish()

    return version.getId()