testing ftrack

This commit is contained in:
Jakub Jezek 2021-10-27 16:50:14 +02:00
parent 48c5372ba5
commit 051e74a448
No known key found for this signature in database
GPG key ID: D8548FBF690B100A

View file

@ -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()