Example #1
0
def any_task(entity=None, path=None, sgfs=None, extra_node_types=None):
    
    sgfs = sgfs or SGFS(session=entity.session if entity else None)
    
    if path:
        entities = list(sgfs.entities_from_path(path))
    elif entity:
        entities = [entity]
    else:
        entities = []
    
    model = Model(sgfs=sgfs)
    model.register_node_type(functools.partial(ShotgunQuery,
        entity_types=['Project', 'Asset', 'Sequence', 'Shot', 'Task'],
    ))
    for node_type in extra_node_types or ():
        model.register_node_type(node_type)

    view = ColumnView()
    view.setModel(model)
    
    if entities:
        state = state_from_entity(entities[0])
        if path:
            state['path'] = path
        initial_index = model.index_from_state(state)
        if initial_index:
            view.setCurrentIndex(initial_index)
        
    return model, view
Example #2
0
def publishes_from_path(path, sgfs=None, publish_types=None, constrain_project=False):
    
    sgfs = sgfs or SGFS()
    
    entities = list(sgfs.entities_from_path(path))
    if not entities:
        raise RuntimeError('No entities for workspace.')
        
    sgfs.session.fetch_heirarchy(entities)
    for entity in list(entities):
        entity = entity.parent()
        while entity and entity not in entities:
            entities.append(entity)
            entity = entity.parent()
    
    if constrain_project:
        model = Model(root_state=state_from_entity(entities[0].project()), sgfs=sgfs)
        model.register_node_type(functools.partial(ShotgunEntities,
            entities=[entities[0].project()],
        ))
    else:
        model = Model(sgfs=sgfs)
        model.register_node_type(functools.partial(ShotgunQuery,
            entity_types=['Project'],
        ))
    
    model.register_node_type(functools.partial(ShotgunQuery,
        entity_types=['Asset', 'Sequence', 'Shot', 'Task'],
    ))
        
    model.register_node_type(functools.partial(ShotgunPublishStream,
        publish_types=publish_types,
    ))
        
        
    view = ColumnView()
    view.setModel(model)
        
    initial_index = model.index_from_state(state_from_entity(entities[0]))
    if initial_index:
        view.setCurrentIndex(initial_index)
        
    return model, view
Example #3
0
def _main():

    import sgfs.commands.utils as command_utils

    optparser = optparse.OptionParser()
    optparser.add_option('-c',
                         '--combobox',
                         action="store_true",
                         dest="combobox")
    optparser.add_option('-r', '--root', dest='root')

    opts, args = optparser.parse_args()

    global model, view, dialog

    sgfs = SGFS()

    if opts.root:
        root = command_utils.parse_spec(sgfs, opts.root.split())
        model = Model(state_from_entity(
            sgfs.session.get(root['type'], root['id'])),
                      sgfs=sgfs)

    else:
        model = Model(sgfs=sgfs)

    # entity = model.sgfs.session.get('Task', 43897)
    # entities = []
    # while entity:
    #     entities.append(entity)
    #     entity = entity.parent()
    # print 'ENTITY', entities
    # model.register_node_type(functools.partial(ShotgunEntities, entities=entities))

    # model.register_node_type(SGFSRoots)
    model.register_node_type(functools.partial(ShotgunPublishStream))
    # model.register_node_type(functools.partial(ShotgunQuery, entity_types=('EventLogEntry', 'ActionMenuItem', 'Step', 'PublishEvent', 'Asset', 'Sequence', 'Shot', 'Task', 'Version', 'Tool', 'Ticket', 'Project', 'HumanUser')))
    model.register_node_type(
        functools.partial(ShotgunQuery,
                          entity_types=('Asset', 'Sequence', 'Shot', 'Project',
                                        'Task')))

    model.register_node_type(
        functools.partial(TemplateGlobPicker,
                          entity_types=('Task', ),
                          template='nuke_scripts_dir',
                          glob='*.nk'))
    # model.register_node_type(functools.partial(DirectoryPicker, entity_types=('Task', ),))

    if opts.combobox:
        view = ComboBoxView()
    else:
        view = ColumnView()

    view.setModel(model)

    type_ = None
    id_ = None

    if args:
        init = command_utils.parse_spec(model.sgfs, args)
        type_ = init.get('type')
        id_ = init.get('id')
        print type_, id_

    if type_ and id_:
        entity = model.sgfs.session.get(type_, id_)
        init_state = state_from_entity(entity)

        index = model.index_from_state(init_state)
        if index:
            view.setCurrentIndex(index)
        else:
            print 'Could not get index for initial state.'

    view.setMinimumWidth(800)

    if not opts.combobox:
        view.setMaximumHeight(400)
        view.setPreviewVisible(False)
        view.setColumnWidths([1] * 10)

    dialog = QtGui.QDialog()
    dialog.setWindowTitle(sys.argv[0])
    dialog.setLayout(QtGui.QHBoxLayout())
    dialog.layout().addWidget(view)
    dialog.layout().addStretch()

    dialog.show()
    dialog.raise_()