forked from vfxetc/sgevents
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite plate republisher with sgpublish plugin framework
- Loading branch information
Showing
2 changed files
with
28 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from sgpublish.republishes import RepublishEventPlugin | ||
from sgpublish import Publisher | ||
|
||
|
||
plugin = __sgevents_init__ = RepublishEventPlugin(name='republish-looper') | ||
|
||
|
||
@plugin.register('dev_loop_1', 'dev_loop_2') | ||
def one_to_two(src): | ||
|
||
with Publisher(template=src, type='dev_loop_2'): | ||
pass | ||
|
||
@plugin.register('dev_loop_2', 'dev_loop_1') | ||
def two_to_one(src): | ||
|
||
with Publisher(template=src, type='dev_loop_1'): | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,10 @@ | ||
import logging | ||
|
||
from sgsession import Session | ||
from shotgun_api3_registry import connect | ||
import qbfutures | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
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(('code', 'sg_link.Task.step.Step.short_name', 'sg_type', 'created_by.HumanUser.login')) | ||
|
||
# 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 | ||
|
||
pub_type = entity.get('sg_type') | ||
if pub_type != 'plate': | ||
log.info('sg_type %r is not plate; skipping' % pub_type) | ||
return | ||
|
||
step_code = entity.get('sg_link.Task.step.Step.short_name') | ||
if step_code not in ('Online', ): | ||
log.info('sg_link.step.short_code %s is not Online; skipping' % step_code) | ||
return | ||
|
||
# TODO: Make sure it doesn't already exist. | ||
|
||
# Run it as the correct user; assume their Shotgun login matches. | ||
login = entity.get('created_by.HumanUser.login') | ||
user = login.split('@')[0] if login else None | ||
|
||
future = qbfutures.submit_ext('kspipeline.edit.plate_publish.core:republish_as_proxy', | ||
args=[entity.minimal], | ||
name='Republish plate %d "%s" as proxy' % (entity['id'], entity['code']), | ||
user=user, | ||
priority=8000, | ||
) | ||
|
||
log.info('republish_as_proxy scheduled on Qube as %d' % future.job_id) | ||
|
||
|
||
__sgevents__ = dict( | ||
type='callback', | ||
callback_in_subprocess=False, | ||
callback=callback, | ||
filter={ | ||
'event_type': 'Shotgun_PublishEvent_Change', | ||
'attribute_name': 'sg_version', | ||
}, | ||
from sgpublish.republishes import RepublishEventPlugin | ||
|
||
plugin = __sgevents_init__ = RepublishEventPlugin(name='republish_as_proxy') | ||
plugin.register( | ||
src_types='plate', | ||
dst_types='plate_proxy', | ||
src_steps='Online', | ||
func='kspipeline.edit.plate_publish.core:republish_as_proxy', | ||
) | ||
|
||
|
||
|