def get_shotgun(shotgun=None): if shotgun is None: eps = list(pkg_resources.iter_entry_points('shotgun_api3_kwargs')) for ep in eps: func = ep.load() shotgun = func() if shotgun: break if shotgun is None: try: import shotgun_api3_registry except ImportError: raise ValueError( 'Shotgun instance is required if no shotgun_api3_kwargs entrypoint or shotgun_sg3_registry:get_args does not exist' ) if hasattr(shotgun_api3_registry, 'get_kwargs'): shotgun = shotgun_api3_registry.get_kwargs() else: shotgun = shotgun_api3_registry.get_args() if isinstance(shotgun, (list, tuple)): shotgun = sgapi.Shotgun(*shotgun) elif isinstance(shotgun, dict): shotgun = sgapi.Shotgun(**shotgun) return shotgun
def get_shotgun_kwargs(config): if config and config.SHOTGUN_URL: return { 'base_url': config.SHOTGUN_URL, 'script_name': config.SHOTGUN_SCRIPT_NAME, 'api_key': config.SHOTGUN_API_KEY, } elif shotgun_api3_registry: # In Western Post, this envvar signals to return the cache. That would # make very little sense here. os.environ.pop('SGCACHE', None) return shotgun_api3_registry.get_kwargs() else: raise RuntimeError( 'please set SHOTGUN_URL, or provide shotgun_api3_registry.get_kwargs' )
def get_shotgun(shotgun=None): if shotgun is None: try: import shotgun_api3_registry except ImportError: raise ValueError('Shotgun instance is required if shotgun_sg3_registry:get_args does not exist') if hasattr(shotgun_api3_registry, 'get_kwargs'): shotgun = shotgun_api3_registry.get_kwargs() else: shotgun = shotgun_api3_registry.get_args() if isinstance(shotgun, (list, tuple)): shotgun = sgapi.Shotgun(*shotgun) elif isinstance(shotgun, dict): shotgun = sgapi.Shotgun(**shotgun) return shotgun
def get_shotgun(shotgun=None): if shotgun is None: try: import shotgun_api3_registry except ImportError: raise ValueError( 'Shotgun instance is required if shotgun_sg3_registry:get_args does not exist' ) if hasattr(shotgun_api3_registry, 'get_kwargs'): shotgun = shotgun_api3_registry.get_kwargs() else: shotgun = shotgun_api3_registry.get_args() if isinstance(shotgun, (list, tuple)): shotgun = sgapi.Shotgun(*shotgun) elif isinstance(shotgun, dict): shotgun = sgapi.Shotgun(**shotgun) return shotgun
from shotgun_api3_registry import get_kwargs from .core import Shotgun sg = Shotgun(**get_kwargs())