예제 #1
0
파일: sgfs.py 프로젝트: westernx/sgfs
 def session(self):
     # Set the session, building it from a generic Shotgun if nothing was
     # given. This requires a `shotgun_api3_registry.connect()` function.
     if not self._shotgun and not self._session:
         import shotgun_api3_registry
         self._shotgun = shotgun_api3_registry.connect(auto_name_stack_depth=1)
     return self._session or Session(self._shotgun)
예제 #2
0
파일: utils.py 프로젝트: vfxetc/sgsession
def shotgun_api3_connect(*args, **kwargs):

    eps = []
    for ep in pkg_resources.iter_entry_points('shotgun_api3_connect'):
        eps.append((ep, True))
    for ep in pkg_resources.iter_entry_points('shotgun_api3_kwargs'):
        eps.append((ep, False))
    eps.sort(key=lambda (ep, _): ep.name)

    for ep, is_direct in eps:

        func = ep.load()
        res = func(*args, **kwargs)
        if not res:
            continue

        if is_direct:
            return res

        import shotgun_api3
        return shotgun_api3.Shotgun(**res)

    # Fall back onto the shotgun_api3_registry module.
    try:
        import shotgun_api3_registry as m
    except ImportError:
        pass
    else:
        return m.connect(*args, **kwargs)

    raise ValueError(
        "No shotgun_api3_connect/shotgun_api3_kwargs entry point or shotgun_api3_registry module found."
    )
예제 #3
0
 def session(self):
     # Set the session, building it from a generic Shotgun if nothing was
     # given. This requires a `shotgun_api3_registry.connect()` function.
     if not self._shotgun and not self._session:
         import shotgun_api3_registry
         self._shotgun = shotgun_api3_registry.connect(
             auto_name_stack_depth=1)
     return self._session or Session(self._shotgun)
예제 #4
0
파일: session.py 프로젝트: hpayer/sgsession
 def shotgun(self):
     # Automatically generate Shotgun when we need one.
     # We use False to track that there should be nothing set here.
     if self._shotgun is None:
         import shotgun_api3_registry
         self._shotgun = ShotgunPool.wrap(shotgun_api3_registry.connect(
             *self._shotgun_args, **self._shotgun_kwargs
         ))
     return self._shotgun or None
예제 #5
0
 def shotgun(self):
     # Automatically generate Shotgun when we need one.
     # We use False to track that there should be nothing set here.
     if self._shotgun is None:
         import shotgun_api3_registry
         self._shotgun = ShotgunPool.wrap(
             shotgun_api3_registry.connect(*self._shotgun_args,
                                           **self._shotgun_kwargs))
     return self._shotgun or None
예제 #6
0
    def __init__(self, shotgun=None, *args, **kwargs):

        # Lookup strings in the script registry.
        if isinstance(shotgun, basestring):
            import shotgun_api3_registry
            shotgun = shotgun_api3_registry.connect(shotgun, *args, **kwargs)

        # Wrap basic shotgun instances in our threader.
        if isinstance(shotgun, _BaseShotgun):
            shotgun = ShotgunPool(shotgun)

        self.shotgun = shotgun
        self._cache = {}
예제 #7
0
파일: session.py 프로젝트: hpayer/sgsession
    def __init__(self, shotgun=None, schema=None, *args, **kwargs):

        # Lookup strings in the script registry.
        if isinstance(shotgun, basestring):
            import shotgun_api3_registry
            shotgun = shotgun_api3_registry.connect(shotgun, *args, **kwargs)

        # Wrap basic shotgun instances in our threader.
        self._shotgun = ShotgunPool.wrap(shotgun)
        self._shotgun_args = None if shotgun else args
        self._shotgun_kwargs = None if shotgun else kwargs

        self._schema = schema

        self._cache = {}
        self._thread_pool = None
예제 #8
0
    def __init__(self, shotgun=None, schema=None, *args, **kwargs):

        # Lookup strings in the script registry.
        if isinstance(shotgun, basestring):
            import shotgun_api3_registry
            shotgun = shotgun_api3_registry.connect(shotgun, *args, **kwargs)

        # Wrap basic shotgun instances in our threader.
        self._shotgun = ShotgunPool.wrap(shotgun)
        self._shotgun_args = None if shotgun else args
        self._shotgun_kwargs = None if shotgun else kwargs

        self._schema = schema

        self._cache = {}
        self._thread_pool = None
예제 #9
0
def get_shotgun(*args, **kwargs):

    if ('SHOTGUN_SERVER' in os.environ and
        'SHOTGUN_SCRIPT_NAME' in os.environ and
        'SHOTGUN_SCRIPT_KEY' in os.environ):
        return shotgun_api3.Shotgun(
            os.environ['SHOTGUN_SERVER'],
            os.environ['SHOTGUN_SCRIPT_NAME'],
            os.environ['SHOTGUN_SCRIPT_KEY'],
        )

    try:
        import shotgun_api3_registry
    except ImportError:
        raise RuntimeError("Set $SHOTGUN_{SERVER,SCRIPT_NAME,SCRIPT_KEY} or provide shotgun_api3_registry.connect()")
    else:
        return shotgun_api3_registry.connect(*args, **kwargs)
예제 #10
0
def get_shotgun(*args, **kwargs):

    if ('SHOTGUN_SERVER' in os.environ and
        'SHOTGUN_SCRIPT_NAME' in os.environ and
        'SHOTGUN_SCRIPT_KEY' in os.environ):
        return shotgun_api3.Shotgun(
            os.environ['SHOTGUN_SERVER'],
            os.environ['SHOTGUN_SCRIPT_NAME'],
            os.environ['SHOTGUN_SCRIPT_KEY'],
        )

    try:
        import shotgun_api3_registry
    except ImportError:
        raise RuntimeError("Set $SHOTGUN_API3_ARGS or provide shotgun_api3_registry.connect()")
    else:
        return shotgun_api3_registry.connect(*args, **kwargs)
예제 #11
0
def callback(event):

    # Must be setting it to a non-zero version.
    # NOTE: We MUST check the meta for this, otherwise we are liable to
    # schedule this job multiple times as the `entity` field is always
    # up to date.
    version = event.meta.get('new_value')
    if not version:
        log.info('Publish is still being created; skipping')
        return

    sg = Session(connect())

    entity = sg.merge(event)['entity']
    if not entity:
        log.info('Publish appeares to have been retired; skipping')
        return

    entity.fetch(('sg_link', 'sg_link.Task.step.Step.short_name', 'sg_type'))

    # For now, we only run for the Testing Sandbox.
    #if event['project']['id'] != 66:
    #    log.info('Project %r in not Testing Sandbox; skipping' % (event['project'].get('name') or event['project']['id']))
    #    return

    # Our first job, is to create camera and geocache publishes from generic maya scenes.
    pub_type = entity.get('sg_type')
    if pub_type != 'maya_scene':
        log.info('sg_type %r is not maya_scene; skipping' % pub_type)
        return
    step_code = entity.get('sg_link.Task.step.Step.short_name')
    if step_code not in ('Anim', 'Roto', 'Rotomation'):
        log.info('sg_link.step.short_code %s is not Anim or Roto; skipping' %
                 step_code)
        return

    # TODO: Make sure they don't already exist.

    log.info('Delegating to sgactions')
    call_in_subprocess('%s:republish' % __file__, [entity['id']])
예제 #12
0
def callback(event):
    
    # Must be setting it to a non-zero version.
    # NOTE: We MUST check the meta for this, otherwise we are liable to
    # schedule this job multiple times as the `entity` field is always
    # up to date.
    version = event.meta.get('new_value')
    if not version:
        log.info('Publish is still being created; skipping')
        return

    sg = Session(connect())
    
    entity = sg.merge(event)['entity']
    if not entity:
        log.info('Publish appeares to have been retired; skipping')
        return
        
    entity.fetch(('sg_link', 'sg_link.Task.step.Step.short_name', 'sg_type'))

    # For now, we only run for the Testing Sandbox.
    #if event['project']['id'] != 66:
    #    log.info('Project %r in not Testing Sandbox; skipping' % (event['project'].get('name') or event['project']['id']))
    #    return

    # Our first job, is to create camera and geocache publishes from generic maya scenes.
    pub_type = entity.get('sg_type')
    if pub_type != 'maya_scene':
        log.info('sg_type %r is not maya_scene; skipping' % pub_type)
        return
    step_code = entity.get('sg_link.Task.step.Step.short_name')
    if step_code not in ('Anim', 'Roto', 'Rotomation'):
        log.info('sg_link.step.short_code %s is not Anim or Roto; skipping' % step_code)
        return
    
    # TODO: Make sure they don't already exist.
    
    log.info('Delegating to sgactions')
    call_in_subprocess('%s:republish' % __file__, [entity['id']])
예제 #13
0
파일: main.py 프로젝트: westernx/sgviewer
def Shotgun():
    return Session(shotgun_api3_registry.connect("sgviewer"))
예제 #14
0
파일: main.py 프로젝트: westernx/sgviewer
def shotgun_api(request_type):
    sg = shotgun_api3_registry.connect()
    func = getattr(sg, request_type)
    print request.content_type
    return func(**request.json)
예제 #15
0
파일: common.py 프로젝트: vfxetc/sgfs
 def Shotgun():
     return shotgun_api3_registry.connect('sgsession.tests',
                                          server=_shotgun_server)
예제 #16
0
파일: common.py 프로젝트: hasielhassan/sgfs
 def Shotgun():
     return shotgun_api3_registry.connect('sgsession.tests', server=_shotgun_server)
예제 #17
0
파일: main.py 프로젝트: westernx/sgviewer
def shotgun_api(request_type):
    sg = shotgun_api3_registry.connect()
    func = getattr(sg, request_type)
    print request.content_type
    return func(**request.json)
예제 #18
0
from shotgun_api3_registry import get_args, get_kwargs, connect

sg = connect()
예제 #19
0
파일: schema.py 프로젝트: hpayer/sgschema









if __name__ == '__main__':

    import time
    from shotgun_api3_registry import connect

    sg = connect(use_cache=False)

    schema = Schema()

    if False:
        schema.read(sg)
        schema.dump('sandbox/raw.json', raw=True)
    else:
        schema.load_raw('sandbox/raw.json')

    schema.dump('sandbox/reduced.json')
    schema.dump('/tmp/reduced.json')

    t = time.time()
    schema = Schema()
    schema.load('/tmp/reduced.json')
예제 #20
0
파일: main.py 프로젝트: westernx/sgviewer
def Shotgun():
    return Session(shotgun_api3_registry.connect('sgviewer'))
예제 #21
0
파일: dump.py 프로젝트: westernx/sgschema
import sgschema


parser = argparse.ArgumentParser()
parser.add_argument('-n', '--name')
parser.add_argument('-r', '--registry-name')
parser.add_argument('base_url', nargs='?')
parser.add_argument('script_name', nargs='?')
parser.add_argument('api_key', nargs='?')
args = parser.parse_args()


if args.registry_name or not (args.base_url or args.script_name or args.api_key):
    import shotgun_api3_registry
    shotgun = shotgun_api3_registry.connect(args.registry_name)
else:
    shotgun = shotgun_api3.Shotgun(args.base_url, args.script_name, args.api_key)

schema = sgschema.Schema()
schema.read(shotgun)


if not args.name:
    parsed = urlparse.urlparse(shotgun.base_url)
    args.name = parsed.netloc.split('.')[0]

here = os.path.dirname(__file__)

schema._dump_raw(os.path.join(here, args.name + '.'))
schema.dump(os.path.join(here, args.name + '.json'))
예제 #22
0
파일: schema.py 프로젝트: hpayer/sgschema
                        new[field] = value
            else:
                for k, v in x.iteritems():
                    new[k] = self.resolve_structure(v, None, _memo, **kwargs)
            return new

        else:
            return x


if __name__ == '__main__':

    import time
    from shotgun_api3_registry import connect

    sg = connect(use_cache=False)

    schema = Schema()

    if False:
        schema.read(sg)
        schema.dump('sandbox/raw.json', raw=True)
    else:
        schema.load_raw('sandbox/raw.json')

    schema.dump('sandbox/reduced.json')
    schema.dump('/tmp/reduced.json')

    t = time.time()
    schema = Schema()
    schema.load('/tmp/reduced.json')