Jump to content

Delete job under frozen status.


Alberto GZ

Recommended Posts

Thank you Lucas!

One question more...

How I could to use multiple session configurations for the same mark_stalled_jobs_as_failed.py?

I've tried with two external confs and alternating both as import config.py but I have problems with credentials using config2.py. There is another way to do this? I mean, can execute this script for two different ftrack-servers (at same time or not).
 

config1.py

import os

os.environ['FTRACK_SERVER'] = 'ftrack-server-1'
os.environ['FTRACK_APIKEY'] = 'api-key-1'
os.environ['LOGNAME'] = 'user-1'

 

config2.py

import os

os.environ['FTRACK_SERVER'] = 'ftrack-server-2'
os.environ['FTRACK_APIKEY'] = 'api-key-2'
os.environ['LOGNAME'] = 'user-2'
Link to comment
Share on other sites

Yes, that should be possible.

The script initializes the session without specifying server URL or API credentials, so it will pick up those from environment variables. (see Understanding sessions - connection, Environment variables). Note that the environment variables you set are for the legacy API. These work for the new API as well, but should the environment variables for the new API be set (FTRACK_API_USER, FTRACK_API_KEY) be set they will take precedence.

session = ftrack_api.Session()

You can e.g. set the environment variables in your shell before executing the script, or create a new python script (like the ones you have) which sets the credentials and then sources (imports) mark_stalled_jobs_as_failed.

Regards,
Lucas

Link to comment
Share on other sites

I am not sure if I am understanding your question correctly. You can use the new API against multiple ftrack servers.

You could do this by passing the credentials directly:

session_server_1 = ftrack_api.Session(server_url='https://server-1.ftrackapp.com', ...)
session_server_2 = ftrack_api.Session(server_url='https://server-2.ftrackapp.com', ...)

 

By setting the credentials in your environment/shell:

# Execute script using server-1
export FTRACK_SERVER=https://server-1.ftrackapp.com
export FTRACK_API_USER=john.doe@example.org
export FTRACK_API_KEY=cb268ecc-8809-11a3-a7e2-20c9d081909b
python my_script.py

# Execute script using server-2
export FTRACK_SERVER=https://server-2.ftrackapp.com
export FTRACK_API_USER=jane.doe@example.org
export FTRACK_API_KEY=3a372bde-15bc-11e4-8908-20c9d081909b
python my_script.py

 

Or by setting them as environment variables within a python script (like in your examples) and then creating a session. 

Link to comment
Share on other sites

Yes, that's my question.

If I set a unique config.py with same as in example code, then run only for the last environment var entries. I've using import config.py in my_script.py

import os

#ftrack-server-1
os.environ['FTRACK_SERVER'] = 'https://server-1.ftrackapp.com'
os.environ['FTRACK_API_KEY'] = 'api-key-1'
os.environ['FTRACK_API_USER'] = 'user-1'

#ftrack-server-2
os.environ['FTRACK_SERVER'] = 'https://server-2.ftrackapp.com'
os.environ['FTRACK_API_KEY'] = 'api-key-2'
os.environ['FTRACK_API_USER'] = 'user-2'

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...