diff --git a/openpype/hosts/flame/utility_scripts/openpype_flame_to_ftrack.py b/openpype/hosts/flame/utility_scripts/openpype_flame_to_ftrack.py index 5f9a78ce16..2f40c25e88 100644 --- a/openpype/hosts/flame/utility_scripts/openpype_flame_to_ftrack.py +++ b/openpype/hosts/flame/utility_scripts/openpype_flame_to_ftrack.py @@ -1,6 +1,6 @@ from __future__ import print_function from PySide2 import QtWidgets, QtCore - +from pprint import pformat class FlameTreeWidget(QtWidgets.QTreeWidget): """ @@ -61,7 +61,6 @@ def main_window(selection): import flame # identificar as informacoes dos segmentos na timeline - for sequence in selection: for ver in sequence.versions: for tracks in ver.tracks: @@ -91,8 +90,59 @@ def main_window(selection): tree.selectAll() def send_to_ftrack(): + import ftrack_api + + def validate_credentials(url, user, api): + first_validation = True + if not user: + print('- Ftrack Username is not set') + first_validation = False + if not api: + print('- Ftrack API key is not set') + first_validation = False + if not first_validation: + return False + + try: + session = ftrack_api.Session( + server_url=url, + api_user=user, + api_key=api + ) + session.close() + except Exception as _e: + print( + "Can't log into Ftrack with used credentials: {}".format( + _e) + ) + ftrack_cred = { + 'Ftrack server': str(url), + 'Username': str(user), + 'API key': str(api), + } + + item_lens = [len(key) + 1 for key in ftrack_cred] + justify_len = max(*item_lens) + for key, value in ftrack_cred.items(): + print('{} {}'.format((key + ':').ljust( + justify_len, ' '), value)) + return False + print( + 'Credentials Username: "{}", API key: "{}" are valid.'.format( + user, api) + ) + return True + + # fill your own credentials + url = "" + user = "" + api = "" + + if validate_credentials(url, user, api): + print("validation of ftrack went trough") + # Get all selected items from treewidget - clip_info = '' + clips_info = [] for item in tree.selectedItems(): tree_line = [ @@ -104,7 +154,9 @@ def main_window(selection): item.text(5) ] print(tree_line) - clip_info += tree_line + '\n' + clips_info.append(tree_line) + + print("selected clips: {}".format(pformat(clips_info))) # creating ui window = QtWidgets.QWidget()