Jump to content

Mattias Lagergren

Administrators
  • Posts

    1,083
  • Joined

  • Last visited

  • Days Won

    90

Reputation Activity

  1. Thanks
    Mattias Lagergren got a reaction from matthew salt in Subscribe to a Ftrack object   
    Hi Remus, thank you for the request - we are already considering this (follow/unfollow) as part of a future change to the notifications feature. I will make sure to incorporate this information any future research
  2. Like
    Mattias Lagergren got a reaction from Andriy Babak in Multiple instance of Ftrack-Connect   
    Unfortunately there is no reliable way of detecting the machine from the browser, not in a way that can be re-created from python.
    I've made a small plugin (see code below) that detects if there are multiple instances of Connect running for a user and pops up a message. If this functionality makes sense and you like it, we may bundle the plugin in Connect.
    import logging import socket import functools from QtExt import QtWidgets, QtCore import ftrack_api import ftrack_connect.util import ftrack_connect.ui.application logger = logging.getLogger( 'multiple-instances-plugin' ) def open_warning_dialog(message): '''Open warning window.''' parent = None for item in QtCore.QCoreApplication.instance().topLevelWidgets(): if isinstance(item, ftrack_connect.ui.application.Application): parent = item dialog = QtWidgets.QMessageBox(parent=parent) dialog.setText(message) dialog.setIcon(QtWidgets.QMessageBox.Critical) dialog.exec_() def handle_reply(event): '''Handle reply event if someone else is already running Connect.''' logger.warning('Someone else is already running connect: {0}'.format(event)) ftrack_connect.util.invoke_in_main_thread( open_warning_dialog, u'ftrack Connect is already running on machine: {0}'.format( event['data']['machine'] ) ) def callback(event): '''Handle start of another connect.''' logger.warning('Someone just started ftrack Connect: {0}'.format(event)) ftrack_connect.util.invoke_in_main_thread( functools.partial( open_warning_dialog, u'Connect just opened on machine: {0}'.format( event['data']['machine'] ) ) ) return {'machine': socket.gethostname()} def register(session, **kw): '''Register hooks.''' logger.info( 'Register detection of multiple Connect instances' ) # Validate that session is an instance of ftrack_api.session.Session. If # not, assume that register is being called from an old or incompatible API # and return without doing anything. if not isinstance(session, ftrack_api.Session): logger.debug( 'Not subscribing plugin as passed argument {0!r} is not an ' 'Session instance.'.format(session) ) return session.event_hub.subscribe( 'topic=studio.ftrack-connect.start and source.id != "{0}" and ' 'data.username = "{1}"'.format( session.event_hub.id, session._api_user ), callback ) session.event_hub.publish( ftrack_api.event.base.Event( topic='studio.ftrack-connect.start', data={ 'username': session._api_user, 'machine': socket.gethostname() } ), on_reply=handle_reply ) To use it create a folder detect-multi-instance/hook/ inside the ftrack connectp plugins folder, and add the code in a plugin.py (don't forget the hook/ folder). Restart Connect for the plugin to source.
    This simple example could be extended with the ability to "quit" other instances of ftrack Connect.
  3. Thanks
    Mattias Lagergren got a reaction from Mani Varma in Removing a component from a Note   
    Hi,
    With the code you have there you are only removing the component file from the server location.
    Instead, try to remove the component itself:
    session.delete(component) session.commit()  
  4. Thanks
    Mattias Lagergren got a reaction from Chandler in Enforcing project and shot naming convention?   
    Hi and thank you all for your feedback. We understand the motivation for validating input and will take this into consideration for future development. As I understand it and what I've heard from other customers is that the project code, but also shot / asset / task names should be validated.
    A suggestion in the first post is to have a regexp to control this, what do you think about this? Would that be enough for your use-cases?
     
    Thank you for highlighting this. The ftrack.validate event is deprecated and we will make sure to remove it from the documentation.
  5. Like
    Mattias Lagergren got a reaction from Remus Avram in send custom notifications via ftrack_api   
    No updates as of now - as an additional workaround, have you looked into writing a message (note without parent) to the user? This should trigger a notification
    note = session.create('Note', { 'content': 'hey', 'user_id': author_user_id}) sesssion.create('Recipient', { 'note_id': note['id'], 'resource_id': target_user_id }) session.commit()  
  6. Like
    Mattias Lagergren got a reaction from kristin in Time logging   
    Thank you for reporting, I was not aware of this and at the moment we've restricted time-logging to task and this sounds like a bug.
  7. Thanks
    Mattias Lagergren got a reaction from Tim Edelmann in dynamic enumerator and current selection   
    Hi Tim,
    Sorry for the confusion on this - you're correct, the id is wrong when accessed from the sidebar. To work around this you can do the following:
    if '_' in entityId realId, junk = entityId.split('_') As for the entityType - this is old style entity type from the backend. Instead of using 'task' you would want to use 'TypedContext' on the session:
    session.get('TypedContext', realId)  
  8. Thanks
    Mattias Lagergren got a reaction from Tim Edelmann in Creating new events using API   
    To attach a calendar event to a user you will want to create a CalendarEventResource with the calendar_event_id and resource_id (the id of the user).
  9. Thanks
    Mattias Lagergren got a reaction from Ahmed Ammash in mobile version need work   
    Hi, thank you for this input. I will forward this feedback to the team for future considerations.
  10. Like
    Mattias Lagergren got a reaction from Remus Avram in Subscribe to a Ftrack object   
    Hi Remus, thank you for the request - we are already considering this (follow/unfollow) as part of a future change to the notifications feature. I will make sure to incorporate this information any future research
  11. Like
    Mattias Lagergren got a reaction from Philip in How to make a version reviewable via new api   
    Aha, yes - correct - and the example is broken!
    So what happens in the backend is that the service use will asynchronously encode the media. When that is done the new component will be added to the server location. When the example was written it was possible to set a component as thumbnail even though it did not exist in server location. That has changed and we're now verifying this.
    We will discuss here and see what the best approach is and then update the example. Thank you for making us aware of this!
     
  12. Like
    Mattias Lagergren got a reaction from Andy Clarke in Publish comp from within Nuke Studio   
    Hi Andy,
    As of now it is not possible. However, we're about to do some major improvements to our integrations and this sounds like something that we should think about when revising the Nuke plugin!
  13. Like
    Mattias Lagergren reacted to Milan Kolar in Simplify plugins in Connect   
    So I had some time to play with this a little bit and came up with compact and quite efficient way of dealing with environments using launching events. Technically all that is needed is one hook that listens to the launching events and appends environments from simple .json config files based on app identifiers.
    The hook looks for .json files in 'FTRACK_APP_ENVIRONMENTS' and tries to find 2 configs. One that is version independent i.e. 'maya.json' and one that is version dependent i.e. 'maya_2016.json', then it adds both into the environment. Config file names mus match the app identifier or the first part of the identifier when split by '_'.
    You can then have a hierarchical environment config files, where maya.json loads regardless of maya version you launch, and maya_2016.json gets added on top of the environment when you launch Maya 2016 from ftrack.
    'FTRACK_APP_ENVIRONMENTS' folder can then look like this for instance:
    maya.json maya_2015.json maya_2016.json maya_2016.5.json nuke.json nuke_9.0v8.json houdini.json houdini_15.json etc....  
    This is the core part of the hook (full hook attached):
    def modify_application_launch(event): '''Modify the application environment and start timer for the task.''' data = event['data'] context = data['context'] app = data['application'] environment = data['options']['env'] env_path = os.environ.get('FTRACK_APP_ENVIRONMENTS') env_files = [] # determine config file for version independent environment app_name = app['identifier'].split('_')[0] app_file_name = '{}.json'.format(app_name) env_files.append(os.path.join(env_path, app_file_name)) # determine config file for version dependent environment variant_file_name = '{}.json'.format(app['identifier']) env_files.append(os.path.join(env_path, variant_file_name)) env_add = [] # loop through config files for env_file in env_files: try: env_add = load_env(env_file) except: env_add = None # Add each path in config file to the environment if env_add: for variable in env_add: for path in env_add[variable]: ftrack_connect.application.appendPath( str(path), str(variable), environment )  
    This is what the config file look like then:
    { "MAYA_PLUG_IN_PATH": [ "K:\\.core\\dev\\maya\\plug-ins" ], "MAYA_AUTOSAVE_FOLDER": [ "C:\\mayatemp\\autosave" ], "MAYA_SCRIPT_PATH": [ "K:\\.core\\dev\\maya\\scripts", "K:\\.core\\dev\\maya\\shelves", "K:\\.core\\repos\\maya\\scripts", "K:\\.core\\repos\\maya\\prefs\\shelves" ] }  
    Now quite frankly, I think that a simple hook like this (probably a bit more robust version) should be a part of the default connect installation. Straight away people would have 3 options of modifying the app launches. 
    Only need to modify environment: Add your json formatted environment file to 'FTRACK_APP_ENVIRONMENTS' and name it 'app_identifier.json' (e.g.: maya_2016.json) Write your own hook that catches launching events and modify the launch that way. Change the launcher hook in connect and modify to your heart's content  
    One way or another, our enviro setups just went from lot's of python file, to a simple json file per app without the need to tinker with default hooks. Thumbs up.
    modify_app_launch.py
  14. Like
    Mattias Lagergren got a reaction from tokejepsen in Simplify plugins in Connect   
    No problems aside from those you already handle; that it overrides all built-in event plugin hooks if you're not careful.
    The FTRACK_CONNECT_PLUGIN_PATH and default plugin folder is meant to be a standardised way of sharing plugins. The nesting of <root-folder>/<plugin-folder>/hook/ is there to allow separation of plugins from different vendors, and the hook/ folder is there since Connect walks the folder structure down looking for any .py/.pyc file that has a register function. So if you have complex integrations with their own hooks you do not want to source those (let me know if you want me to elaborate on this).
    If you prefer FTRACK_EVENT_PLUGIN_PATH that is still fine, if you want to use FTRACK_CONNECT_PLUGIN_PATH you can still do sort of a flat structure and put all hooks in one dir: <root-folder>/my_studio/hook/
  15. Like
    Mattias Lagergren got a reaction from tokejepsen in Simplify plugins in Connect   
    I think you should prefer using FTRACK_CONNECT_PLUGIN_PATH whenever possible. In what way doesn't it work, nothing happens? Be careful to structure the plugins correctly, see this article: http://ftrack-connect.rtd.ftrack.com/en/latest/developing/plugins.html#plugins
     
     
  16. Like
    Mattias Lagergren got a reaction from tokejepsen in Simplify plugins in Connect   
    I think modifying it should be fine since options it will then be used when doing is used with subprocess.Popen
    The application and context is just sent for reference, the command and options can be modified to tweak what is launched.
    If you've got the time it would be very nice if you could fork and create a pull-request for this. A ftrack.connect.application.after-launch hook, with the pid and some meta data. If you do this it would be great if you could add some documentation about the event as well! :-)
  17. Like
    Mattias Lagergren reacted to Milan Kolar in Simplify plugins in Connect   
    This is getting very close to a simple a straightforward system. I have however ran into some issues.
    The most prominent right now is the fact that I have no way of finding out what task/entity was the source of this launching event. It's not included in the event data and because it seems that this event precedes the ftrack addition of env variables the environment is missing the 'FTRACK_TASKID' key too.  It's important to be able to tell what originated the launch event because the enviro usually changes based on what project or task we're launching (different plugins for example.
     
    EDIT:
    Ah. One of those where you completely skip on part of docs and then realise it's of course all there. If anyone else enjoys skipping important parts of docs, then here's how you get it.
    event['data']['context']['selection'][0]['entityId'] So considering I found it...Nice work guys.
  18. Like
    Mattias Lagergren got a reaction from tokejepsen in Simplify plugins in Connect   
    The feature I mentioned above is released and you can find more information here: 
    http://ftrack-connect.rtd.ftrack.com/en/0.1.21/using/plugin_directory.html
    http://ftrack-connect.rtd.ftrack.com/en/0.1.21/developing/plugins.html
    http://ftrack-connect.rtd.ftrack.com/en/0.1.21/developing/hooks/application_launch.html#ftrack-connect-application-launch
     
    You can reply here with questions or feedback!
  19. Like
    Mattias Lagergren got a reaction from Fredrik Limsater in Simplify plugins in Connect   
    Hi everyone! 
    I'm writing here to let you know that we are working on some changes to make Connect easier to extend and develop plugins for.  Some of you I've already been in contact with but I would love to hear the feedback and opinions from the Community.
    We have a lot of ideas that we want to implement in Connect but the plan is to start out by tackling two common issues:
    Extending and modifying the environment and command when an application starts from Connect. Adding hooks to Connect without modifying the FTRACK_EVENT_PLUGIN_PATH. The way we intend to solve this is:
    Emit an event every time an application is launched from Connect. The event will contain application identifier, context, command and options that contain the environment variables. Here you will be able to make changes to environment variables, command and options. This should allow a lot of flexibility without having to override the built-in hook it-self. A platform dependent default directory from where plugins can be discovered without modifications to FTRACK_EVENT_PLUGIN_PATH. E.g. on OS X it would be something like /Users/mattiaslagergren/Library/Application Support/ftrack-connect-plugins/. We also intend to give the option set an environment variable so that you can centralise the plugins to one directory that everyone in the studio reads from. Connect will pick up plugins from both places.
×
×
  • Create New...