PF_Wags

Members
  • Content count

    4
  • Joined

  • Last visited

  1. ftrack-example-create-folders-action

    @UrbanCircus I pieced together getting files created from an action but unfortunately haven't made any progress to populate the directories based on the structure of my project. import logging import ftrack_api import errno import os class MyCustomAction(object): '''Custom action.''' label = 'createfolders' identifier = 'my.custom.action' description = 'This is an example action creating folders' def __init__(self, session): '''Initialise action.''' super(MyCustomAction, self).__init__() self.session = session self.logger = logging.getLogger( __name__ + '.' + self.__class__.__name__ ) def register(self): '''Register action.''' self.session.event_hub.subscribe( 'topic=ftrack.action.discover and source.user.username={0}'.format( self.session.api_user ), self.discover ) self.session.event_hub.subscribe( 'topic=ftrack.action.launch and data.actionIdentifier={0} and ' 'source.user.username={1}'.format( self.identifier, self.session.api_user ), self.launch ) def discover(self, event): '''Return action config if triggered on a single asset version.''' # If selection contains more than one item return early since # this action can only handle a single version. selection = event['data']['selection'] self.logger.info('Got selection: {0}'.format(selection)) # action works in the task context if len(selection) != 1 or selection[0]['entityType'] != 'task': return return { 'items': [{ 'label': self.label, 'description': self.description, 'actionIdentifier': self.identifier }] } def launch(self, event): '''Callback method for custom action.''' path = 'C:\\project\\test\\' try: os.makedirs(path) except OSError as error: if error.errno != errno.EEXIST: raise return { 'success': True, 'message': 'did it work?' } def register(session, **kw): '''Register plugin.''' # Validate that session is an instance of ftrack_api.Session. If not, # assume that register is being called from an incompatible API # and return without doing anything. if not isinstance(session, ftrack_api.Session): # Exit to avoid registering this plugin again. return action = MyCustomAction(session) action.register() if __name__ == '__main__': logging.basicConfig(level=logging.INFO) session = ftrack_api.Session() register(session) # Wait for events. session.event_hub.wait()
  2. python API tutorial error

    That was it! Thanks for the help.
  3. python API tutorial error

    Hello, I am trying to follow th python_API tutorial but I cant connect to my server. What am I missing? I am following the code from the tutorial with my server, api key, and username but I get the following error >>> session = ftrack_api.Session( ... server_url='http://mycompany.ftrackapp.com', ... api_key='7545384e-a653-11e1-a82c-f22c11dd25eq', ... api_user='martin' ... ) Traceback (most recent call last): File "<stdin>", line 4, in <module> File "C:\Python27\lib\site-packages\ftrack_api\session.py", line 224, in __init__ self._server_information = self._fetch_server_information() File "C:\Python27\lib\site-packages\ftrack_api\session.py", line 1317, in _fetch_server_information result = self._call([{'action': 'query_server_information'}]) File "C:\Python27\lib\site-packages\ftrack_api\session.py", line 1620, in _call raise ftrack_api.exception.ServerError(error_message) ftrack_api.exception.ServerError: Server reported error: HTTPMethodNotAllowed()
  4. Hi All, I am just going through some actions examples and I am looking for the example code from this video https://vimeo.com/90867308 The link in the comments doesn't seem to work anymore. Anyone have the example code somewhere else that they can post? cheers, Steve