-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_client.py
executable file
·88 lines (71 loc) · 2.56 KB
/
create_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! /usr/bin/env python
# Copyright (c) 2019 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
from __future__ import print_function, absolute_import
import sgtk
import json
from framework import patch_environment
def main():
from python.create_client import CreateClient, ensure_create_server_is_running
user = sgtk.authentication.ShotgunAuthenticator().get_default_user()
if not user:
print("Unable to create a Desktop Client unauthenticated.")
return 1
sgtk.set_authenticated_user(user)
if not ensure_create_server_is_running(user.create_sg_connection()):
print("Failed to ensure that ShotGrid Create is running")
return 2
client = CreateClient(user.create_sg_connection())
commands = client.call_server_method("list_supported_commands")
print("CreateClient standalone client")
print()
print("Usage:")
print("> COMMAND :: ARGUMENT")
print()
print()
print("Example:")
print('> sgc_open_task_board :: { "project_id" : null }')
print()
print()
print("Available commands:")
for command in sorted(commands):
print(" - " + str(command))
print()
while True:
try:
print("Enter command ('exit' to exit )")
try:
user_input = raw_input("> ").strip()
except NameError:
user_input = input("> ").strip
if not user_input:
continue
if user_input == "exit":
return 0
if "::" in user_input:
command, args = user_input.split("::")
command = str(command.strip())
args = str(args.strip())
else:
command = user_input.strip()
args = "{}"
print()
print("Command: {0}".format(command))
print("Arguments: {0}".format(args))
print()
server_resp = client.call_server_method(command, json.loads(args))
print(json.dumps(server_resp, indent=2, sort_keys=True))
print()
except RuntimeError as e:
print(str(e))
pass
if __name__ == "__main__":
patch_environment()
exit(main())