def get_dam_session(dam_type="strack"): if dam_type == "shotgun": from shotgun_api3.shotgun import Shotgun return Shotgun(SHOTGUN_URL, SHOTGUN_SCRIPT, SHOTGUN_API_KEY) else: from strack_api.strack import Strack return Strack(STACK_SERVER_URL, STACK_USER, STACK_PASSWD)
def get_shotgun_handler(root_config): """Get shotgun handler instance. Returns: shotgun_api3.shotgun.Shotgun: shotgun instance. """ shotgun_library_path = root_config['library_paths']['shotgun'] sys.path.append(shotgun_library_path) try: from shotgun_api3.shotgun import Shotgun shotgun_connection_config = root_config['source_generator']['shotgun'][ 'connection'] shotgun_handler = Shotgun( shotgun_connection_config['site'], script_name=shotgun_connection_config['script_name'], api_key=shotgun_connection_config['api_key']) return shotgun_handler except Exception as e: logger = logging.getLogger(__name__) logger.error(e) return None
def _connect(): conf = config.Configuration() conn = connectors.getDBConnection() cur = conn.cursor() sg = Shotgun(conf.get(config.CONF_SHOTGUN_URL), conf.get(config.CONF_SHOTGUN_SYNC_SKRIPT), conf.get(config.CONF_SHOTGUN_SYNC_KEY)) return (conn, cur, sg)
def main(): """ to be called """ sg_url = "https://devilfant.shotgunstudio.com" sg_test1 = { "name": "test1", "key": "e398654c5ec1c6f7c8f71ead33349c58bbf4a058" } sg1 = Shotgun(sg_url, sg_test1["name"], sg_test1["key"]) entities = sg1.schema_entity_read() pprint(entities) moduleString = """# -*- coding: utf-8 -*- \"""@package shotgun_replica.entities Shotgun Entities THIS FILE IS AUTO GENERATED DO NOT EDIT IT DIRECTLY change create_shotgun_classes.py instead \""" from shotgun_replica._entity_mgmt import _ShotgunEntity from shotgun_replica import %s """ % FIELDDEFINITIONSMODULE fieldDefModuleString = """# -*- coding: utf-8 -*- \""" THIS FILE IS AUTO GENERATED DO NOT EDIT IT DIRECTLY change create_shotgun_classes.py instead \""" """ classes = entities.keys() classes.sort() for entitycode in classes: print "processing %s\n" % entitycode fieldDefs = sg1.schema_field_read(entitycode) try: theclass = connectors.getClassOfType(entitycode) localFieldDefs = theclass.shotgun_fields except ImportError: localFieldDefs = None except AttributeError: localFieldDefs = None if fieldDefs != localFieldDefs: debug.error("%s fielddefs differ from shotgun to local" % entitycode) entityname = cleanSysName(entities[entitycode]["name"]["value"]) if entitycode.endswith("Connection"): entityname = entitycode (classCode, fieldDefCode) = _createClassCode(entities, entitycode, fieldDefs, entityname) moduleString += classCode fieldDefModuleString += fieldDefCode _createDBFields(entitycode, fieldDefs, entityname) packageDir = os.path.dirname(__file__) entityFilename = os.path.join(packageDir, 'entities.py') entity_file = open(entityFilename, 'w') entity_file.write(moduleString) entity_file.close() fieldDefFilename = os.path.join(packageDir, '%s.py' % FIELDDEFINITIONSMODULE) fieldDef_file = open(fieldDefFilename, 'w') fieldDef_file.write(fieldDefModuleString) fieldDef_file.close()