Пример #1
0
 def _create_session_user(self, name, host="https://test.shotgunstudio.com"):
     """
     Shorthand to create a session user.
     """
     return ShotgunAuthenticator().create_session_user(
         name, session_token=name[::-1], host=host
     )
Пример #2
0
 def _create_script_user(self, api_script, host="https://test.shotgunstudio.com"):
     """
     Shorthand to create a script user.
     """
     return ShotgunAuthenticator().create_script_user(
         api_script, api_key=api_script[::-1], host=host
     )
Пример #3
0
def _get_user():
    """
    Authenticate with a Shotgun site.

    If SHOTGUN_HOST, SHOTGUN_USER_LOGIN and SHOGUN_USER_PASSWORD
    are set, then they will be used for authentication. If not,
    the user will be prompted for their credentials if they
    are not already logged into Shotgun.

    :returns: A Shotgun user.
    :rtype: sgtk.authentication.ShotgunUser
    """
    host = os.environ.get("SHOTGUN_HOST")
    login = os.environ.get("SHOTGUN_USER_LOGIN")
    password = os.environ.get("SHOTGUN_USER_PASSWORD")

    from sgtk.authentication import ShotgunAuthenticator

    sg_auth = ShotgunAuthenticator()

    # If all the variables were set, we can authenticate.
    if host and login and password:
        print("Authenticating from environment variables.")
        return sg_auth.create_session_user(login, password=password, host=host)
    elif host or login or password:
        # Something was set, but not everything.
        # Do not print the values, as this can be used in CI.
        print("Not all authentication environment variables were set. "
              "Falling back to interactive authentication.\n"
              "SHOTGUN_HOST: {0}\n"
              "SHOTGUN_USER_LOGIN: {1}\n"
              "SHOTGUN_USER_PASSWORD: {2}\n".format(
                  "set" if host else "unset",
                  "set" if login else "unset",
                  "set" if password else "unset",
              ))

    return sg_auth.get_user()
Пример #4
0
def test_context_tab(about_box):
    """
    Ensure the content of the context browser is complete.
    """
    about_box.select_context_tab()
    user = ShotgunAuthenticator().get_default_user()
    server = urllib.parse.urlparse(user.host).netloc
    assert about_box.context_browser.items == [
        "Project Big Buck Bunny ({0})\nBig Buck Bunny is a short computer animated film by the Blender Institute, part of the Blender Foundation."
        .format(server),
        "Asset Acorn\nAs to size, Alice hastily but Im not looking for eggs, as it spoke. As wet as ever, said Alice to herself, and fanned herself one",
        "Pipeline Step Art\nNo Description",
        "Task Art\nStatus: fin\nAssigned to: Artist 3",
    ]
def get_toolkit_user():
    """
    Authenticate with a Shotgun site.

    If SHOTGUN_HOST, SHOTGUN_USER_LOGIN and SHOGUN_USER_PASSWORD
    or SHOTGUN_HOST, SHOTGUN_SCRIPT_NAME and SHOTGUN_SCRIPT_KEY
    are set, then they will be used for authentication. If not,
    the user will be prompted for their credentials if they
    are not already logged into Shotgun.

    User based authentication has precedence over script based
    authentication.

    :returns: A Shotgun user.
    :rtype: sgtk.authentication.ShotgunUser
    """

    # Lazy loading as Toolkit might not be available yet.
    from sgtk.authentication import ShotgunAuthenticator

    sg_auth = ShotgunAuthenticator()

    return _get_toolkit_user(sg_auth, os.environ)
Пример #6
0
"""

from __future__ import print_function
import sys

sys.path.insert(0, "../../../python")

from sgtk.authentication import ShotgunAuthenticator
from tank_vendor.shotgun_api3.lib import mockgun

# Log on a site.
print("This script will update the Shotgun schema for Mockgun.")
print(
    "Please enter your credentials for the site you wish to clone the schema from. Ideally this would be "
    "a site that has a clean schema like a new site.")
user = ShotgunAuthenticator().get_user_from_prompt()

# Retrieve the schema folder validation
sg = user.create_sg_connection()
schema = sg.schema_read()
schema_entity = sg.schema_entity_read()

print("Validating schema...")
errors = []

# Dictionary of entities that need to be present.
# If the schema has been updated recently and you want to ensure certain fields are present,
# you can set an array of fields to validate for each entity.
schema_requirements = {
    # This is a builtin entity that is disabled by default.
    "Scene": [],
Пример #7
0
"""
This script will update the Shotgun schema for Mockgun.
"""

import sys

sys.path.append("../../../python")

from sgtk.authentication import ShotgunAuthenticator
from tank_vendor.shotgun_api3.lib import mockgun

# Log on a site.
print "This script will update the Shotgun schema for Mockgun."
print "Please enter your credentials for the site you wish to clone the schema from. Ideally this would be "\
    "a site that has a clean schema like a new site."
user = ShotgunAuthenticator().get_user_from_prompt()

# Retrieve the schema folder validation
sg = user.create_sg_connection()
schema = sg.schema_read()
schema_entity = sg.schema_entity_read()

print "Validating schema..."
errors = []

# Dictionary of entities that need to be present.
# If the schema has been updated recently and you want to ensure certain fields are present,
# you can set an array of fields to validate for each entity.
schema_requirements = {
    # This is a builtin entity that is disabled by default.
    "Scene": [],