Esempio n. 1
0
def getentitydatafromshotgun():
    sg = Shotgun(const.SHOTGUN_URL, const.API_NAME, const.API_KEY)
    entityData = sg.schema_entity_read({'type': 'Project', 'id': 70})
    visibleEntities = []
    for entityName in entityData:
        fields = sg.schema_field_read(entityName)
        if 'project' in fields:
            if entityData[entityName]['visible']['value']:
                visibleEntities.append(entityData[entityName]['name']['value'])
                print("\"" + entityData[entityName]['name']['value'] +
                      "\": \"" + entityName + "\",")
    return visibleEntities
def Button_Callback():
	print ""+SCRIPT_NAME+" "+VERSION+"\n"
	print "Connecting to %s..." % (SERVER_PATH),

	sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)
	print "\n\nConnected\n\n"
		
		
		
# ---------------------------------------------------------------------------------------------
# Testing Block BEGIN
# ---------------------------------------------------------------------------------------------

	result = sg.schema_entity_read()
	pprint(result)

	print ""+SERVER_PATH+"\n ... completed\n"
		
	pass
Esempio n. 3
0
class ShotgunUtils():
    '''
    this module is a collection of functions to conect the Asset manager to shogun studio website, to update, create
    and manages all attributes and parameters from the different entities.
    '''
    def __init__(self):
        '''
        creates the connection to the server and connects to database.
        creates list of Ids form the  database collections that needs to convert to shotgun collections

        '''
        '''   shotgun conection '''
        SERVER_PATH = "https://hcpstudio.shotgunstudio.com"
        SCRIPT_NAME = 'sgApi'
        SCRIPT_KEY = '3899a8466f2cea694c2ba5341d871da845509d18d96a4feb7fb8d147de0fa819'

        self.sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)
        '''Shotgun Dictionaries for  status and Piepeline Step and Entity'''

        self.sgStatusList = {
            'CBB': 'cbb',
            'CURRENT': 'crnt',
            'DEPRECATED': 'dep',
            'FINAL': 'fin',
            'HOLD': 'hld',
            'IN PROGRESS': 'ip',
            'OMIT': 'omt',
            'OUTDATED': 'outd',
            'READY TO START': 'rdy',
            'APPROVED': 'apr',
            'REJECTED': 'rej',
            'RETAKE': 'rtk',
            'SUBMIT FOR APPROVAL': 'app',
            'VARIANT': 'vari'
        }

        self.amStatusList = dict(map(reversed, self.sgStatusList.iteritems()))

        self.sgEntityDic = {
            'ITEM': 'Asset',
            'DIGITALMEDIA': 'Version',
            'SHOT': 'shot',
            'SEQUENCE': 'Sequence'
        }
        self.amEntityDic = dict(map(reversed, self.sgEntityDic.iteritems()))
        ''' DAO master conection    '''

        config = ConfigParser.ConfigParser()
        config.read("__database_config.ini")

        master = DaoMaster(instance=config.get('database_connection',
                                               'instance'),
                           db=config.get('database_connection', 'db'))
        session = master.getSession()
        storedFunctions = master.getStoredFunctions()

        self.ItemStatusConvert = storedFunctions.getCatalogItemStatusStoredFunctions(
        )
        self.ShotStatusConvert = storedFunctions.getCatalogShotStatusStoredFunctions(
        )
        self.SequenceStatusConvert = storedFunctions.getCatalogSequenceStatusStoredFunctions(
        )
        self.DMStatusConvert = storedFunctions.getCatalogDigitalMediaStatusStoredFunctions(
        )
        self.TaskStatusConvert = storedFunctions.getCatalogTaskStatusStoredFunctions(
        )
        self.TaskStepConvert = storedFunctions.getCatalogTaskPipelineStepStoredFunctions(
        )
        ''' instance entities from database '''
        self.itemInstance = session.getItemDao()
        self.projectInstance = session.getProjectDao()
        self.sequenceInstance = session.getSequenceDao()
        self.shotInstance = session.getShotDao()
        self.taskInstance = session.getTaskDao()
        self.dmInstance = session.getDigitalMediaDao()
        self.userInstance = session.getUserDao()
        ''' Catalog instance '''
        self.catalogDepartment = session.getCatalogDepartmentDao()
        self.catalogDMType = session.getCatalogDigitalMediaStatusDao()
        self.catalogDMStatus = session.getCatalogDigitalMediaStatusDao()
        self.catalogItemClass = session.getCatalogItemClassDao()
        self.catalogItemComplex = session.getCatalogItemComplexDao()
        self.catalogItemFormat = session.getCatalogItemFormatDao()
        self.catalogItemStatus = session.getCatalogItemStatusDao()
        self.catalogItemType = session.getCatalogItemTypeDao()
        self.catalogSequenceComplex = session.getCatalogSequenceComplexityDao()
        self.catalogSequenceStatus = session.getCatalogSequenceStatusDao()
        self.catalogShotComplex = session.getCatalogShotComplexityDao()
        self.catalogShotPriority = session.getCatalogShotPriorityDao()
        self.catalogShotStatus = session.getCatalogShotStatusDao()
        self.catalogTaskComplex = session.getCatalogTaskComplexityDao()
        self.catalogTaskEntity = session.getCatalogTaskEntityDao()
        self.catalogTaskName = session.getCatalogTaskNameDao()
        self.catalogTaskPipelineStep = session.getCatalogTaskPipelineStepDao()
        self.catalogTaskPriority = session.getCatalogTaskPriorityDao()
        self.catalogTaskStatus = session.getCatalogTaskStatusDao()

        self.ItemStatusList = self.getCatalogItemStatus()
        self.ItemType = self.getCatalogItemType()
        self.ItemClass = self.getCatalogItemCalss()
        self.ItemComplexity = self.getCatalogItemComplex()

        self.Department = self.getCatalogDepartment()

        self.DMStatus = self.getCatalogDMStatus()
        self.DMType = self.getCatalogDMType()

        self.SequenceComplex = self.getCatalogSequenceComplex()
        self.SequenceStatus = self.getCatalogSequenceStatus()

        self.ShotComplex = self.getCatalogShotComplex()
        self.ShotPriority = self.getCatalogShotPriority()
        self.ShotStatus = self.getCatalogShotStatus()

        self.TaskEntity = self.getCatalogTaskEntity()
        self.TaskName = self.getCatalogTaskName()
        self.TaskStep = self.getCatalogTaskPipelineStep()
        self.TaskPriority = self.getCatalogTaskPriority()
        self.TaskStatus = self.getCatalogTaskStatus()
        self.TaskComplex = self.getCatalogTaskComplex()

        self.sgPiepelineStepTag2IdDic = self.getSgStepsDic()
        self.sgPiepelineStepId2TagDic = dict(
            map(reversed, self.sgPiepelineStepTag2IdDic.iteritems()))

    def getParameterSchema(self, fieldType, fieldName=None):
        '''
         utility function to search fields in a given entity.
        :param fieldType: entity to search parameters 'Project', 'Sequence', 'Shot', 'Asset', 'Version', etc.
        :param fieldName: name of the field to search 'id', 'name', 'coce', etc.
        :return: retruns a dictionary with the properties of given parameter
        '''

        squemaDic = self.sg.schema_field_read(fieldType, fieldName)
        print squemaDic
        for field in squemaDic:
            print field
        return squemaDic

    def getEntities(self):
        '''
        utility function to find all the Entities in shotgun for developing
        :return: renturn a list of all entities
        '''
        squemaDic = self.sg.schema_entity_read()
        for entity in squemaDic:
            print entity
        return squemaDic

    def sgDicListFromDaoItemSubscription(self, itemSubscription):

        sgItemDictionaryList = []

        if itemSubscription == []:

            return sgItemDictionaryList

        else:

            for item in itemSubscription:

                subscription = self.itemInstance.readOneByProperties(
                    self.itemInstance.Properties.Id, item)

                if self.sg.find_one(
                        'Asset',
                    [['id', 'is', subscription.getShotgunID()]]):

                    sgDic = {
                        'type': 'Asset',
                        'id': subscription.getShotgunID()
                    }
                    sgItemDictionaryList.append(sgDic)
                else:
                    pass

            return sgItemDictionaryList

    def sgDicListFromDaoShotSubscription(self, shotSubscription):

        sgShotDictionaryList = []

        if shotSubscription == []:

            return sgShotDictionaryList

        else:

            for shot in shotSubscription:
                subscription = self.shotInstance.readOneByProperties(
                    self.shotInstance.Properties.Id, shot)

                if self.sg.find_one(
                        'Shot',
                    [['id', 'is', subscription.getShotgunID()]]):

                    sgDic = {'type': 'Shot', 'id': subscription.getShotgunID()}
                    sgShotDictionaryList.append(sgDic)

                else:
                    pass

            return sgShotDictionaryList

    def sgDicListFromDaoSequenceSubscription(self, sequenceSubscription):

        sgSequenceDictionaryList = []

        if sequenceSubscription == []:

            return sgSequenceDictionaryList

        else:

            for sequence in sequenceSubscription:

                subscription = self.sequenceInstance.readOneByProperties(
                    self.sequenceInstance.Properties.Id, sequence)

                if self.sg.find_one(
                        'Sequence',
                    [['id', 'is', subscription.getShotgunID()]]):

                    sgDic = {
                        'type': 'Sequence',
                        'id': subscription.getShotgunID()
                    }
                    sgSequenceDictionaryList.append(sgDic)

                else:
                    pass

            return sgSequenceDictionaryList

    def sgDicListFromDaoDMSubscription(self, dmSubscription):

        sgDMDictionaryList = []

        if dmSubscription == []:

            return sgDMDictionaryList

        else:

            for dm in dmSubscription:
                subscription = self.dmInstance.readOneByProperties(
                    self.dmInstance.Properties.Id, dm)
                if self.sg.find_one(
                        'Version',
                    [['id', 'is', subscription.getShotgunID()]]):

                    sgDic = {
                        'type': 'Version',
                        'id': subscription.getShotgunID()
                    }
                    sgDMDictionaryList.append(sgDic)

                else:
                    pass

            return sgDMDictionaryList

    def sgDicListFromDaoUserSubscription(self, userSubscription):

        sgUserDictionaryList = []

        if userSubscription == []:

            return sgUserDictionaryList

        else:

            for user in userSubscription:
                subscription = self.userInstance.readOneByProperties(
                    self.userInstance.Properties.Id, user)

                if not subscription.getShotgunID() == 0:
                    if self.sg.find_one(
                            'HumanUser',
                        [['id', 'is', subscription.getShotgunID()]]):
                        sgDic = {
                            'type': 'HumanUser',
                            'id': subscription.getShotgunID()
                        }
                        sgUserDictionaryList.append(sgDic)

                else:
                    pass

            return sgUserDictionaryList

    def sgDicListFromDaoTaskSubscription(self, taskSubscription):

        sgUserDictionaryList = []

        if taskSubscription == []:

            return sgUserDictionaryList

        else:

            for task in taskSubscription:
                subscription = self.taskInstance.readOneByProperties(
                    self.taskInstance.Properties.Id, task)

                if not subscription.getShotgunID() == 0:
                    if self.sg.find_one(
                            'Task',
                        [['id', 'is', subscription.getShotgunID()]]):
                        sgDic = {
                            'type': 'Task',
                            'id': subscription.getShotgunID()
                        }
                        sgUserDictionaryList.append(sgDic)

                else:
                    pass

            return sgUserDictionaryList

    def amItemIdListFromSgItemSubscriptionDicList(self, sgDicList):

        amSubscriptionList = []

        if sgDicList == []:
            return amSubscriptionList

        else:
            for sgDic in sgDicList:
                item = self.itemInstance.readOneByProperties(
                    self.itemInstance.Properties.Id, sgDic['id'])

                if item:
                    amSubscriptionList.append(item.getId())

                else:
                    pass

            return amSubscriptionList

    def amShotIdListFromSgShotSubscriptionDicList(self, sgDicList):

        amSubscriptionList = []

        if sgDicList == []:
            return amSubscriptionList

        else:
            for sgDic in sgDicList:
                entity = self.shotInstance.readOneByProperties(
                    self.shotInstance.Properties.Id, sgDic['id'])

                if entity:
                    amSubscriptionList.append(entity.getId())

                else:
                    pass

            return amSubscriptionList

    def amSequenceIdListFromSgSequenceSubscriptionDicList(self, sgDicList):

        amSubscriptionList = []

        if sgDicList == []:
            return amSubscriptionList

        else:
            for sgDic in sgDicList:
                entity = self.sequenceInstance.readOneByProperties(
                    self.sequenceInstance.Properties.Id, sgDic['id'])

                if entity:
                    amSubscriptionList.append(entity.getId())

                else:
                    pass

            return amSubscriptionList

    def amDMIdListFromSgDMSubscriptionDicList(self, sgDicList):

        amSubscriptionList = []

        if sgDicList == []:
            return amSubscriptionList

        else:
            for sgDic in sgDicList:
                entity = self.dmInstance.readOneByProperties(
                    self.dmInstance.Properties.Id, sgDic['id'])

                if entity:
                    amSubscriptionList.append(entity.getId())

                else:
                    pass

            return amSubscriptionList

    def amTaskIdListFromSgTaskSubscriptionDicList(self, sgDicList):

        amSubscriptionList = []

        if sgDicList == []:
            return amSubscriptionList

        else:
            for sgDic in sgDicList:
                entity = self.dmInstance.readOneByProperties(
                    self.dmInstance.Properties.Id, sgDic['id'])

                if entity:
                    amSubscriptionList.append(entity.getId())

                else:
                    pass

            return amSubscriptionList

    def sgIdFromItemId(self, itemId):
        if not itemId == 0:
            entity = self.itemInstance.readOneByProperties(
                self.itemInstance.Properties.Id, itemId)
            return entity.getShotgunID()
        else:
            return 0

    def sgIdFromShotId(self, shotId):

        if not shotId == 0:
            entity = self.shotInstance.readOneByProperties(
                self.shotInstance.Properties.Id, shotId)
            return entity.getShotgunID()
        else:
            return 0

    def sgIdFromSquenceId(self, sequenceId):

        if not sequenceId == 0:
            entity = self.sequenceInstance.readOneByProperties(
                self.sequenceInstance.Properties.Id, sequenceId)
            return entity.getShotgunID()
        else:
            return 0

    def sgIdFromProjectId(self, projectId):

        if not projectId == 0:
            entity = self.projectInstance.readOneByProperties(
                self.projectInstance.Properties.Id, projectId)
            return entity.getShotgunID()
        else:
            return 0

    def sgIdFromDmId(self, dmId):

        if not dmId == 0:
            entity = self.dmInstance.readOneByProperties(
                self.dmInstance.Properties.Id, dmId)
            return entity.getShotgunID()

        else:
            return 0

    def sgIdFromTaskId(self, taskId):

        if not taskId == 0:
            entity = self.taskInstance.readOneByProperties(
                self.taskInstance.Properties.Id, taskId)
            return entity.getShotgunID()

        else:
            return 0

    def getCatalogDepartment(self):

        listFromCatalog = []

        catalogAll = self.catalogDepartment.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogDMStatus(self):

        listFromCatalog = []

        catalogAll = self.catalogDMStatus.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogDMType(self):

        listFromCatalog = []

        catalogAll = self.catalogDMType.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogItemCalss(self):

        listFromCatalog = []

        catalogAll = self.catalogItemClass.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogItemComplex(self):

        listFromCatalog = []

        catalogAll = self.catalogItemComplex.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def itemStatus2Dao(self, status):

        return self.ItemStatusConvert.getIdFromTag(status)

    def shotStatus2Dao(self, status):

        return self.ShotStatusConvert.getIdFromTag(status)

    def sequenceStatus2Dao(self, status):

        return self.SequenceStatusConvert.getIdFromTag(status)

    def dmStatus2Dao(self, status):

        return self.SequenceStatusConvert.getIdFromTag(status)

    def taskStatus2Dao(self, status):

        return self.TaskStatusConvert.getIdFromTag(status)

    def getCatalogItemStatus(self):

        listFromCatalog = []

        catalogAll = self.catalogItemStatus.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogItemType(self):

        listFromCatalog = []

        catalogAll = self.catalogItemType.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogSequenceComplex(self):

        listFromCatalog = []

        catalogAll = self.catalogSequenceComplex.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogSequenceStatus(self):

        listFromCatalog = []

        catalogAll = self.catalogSequenceStatus.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogShotComplex(self):

        listFromCatalog = []

        catalogAll = self.catalogShotComplex.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogShotPriority(self):

        listFromCatalog = []

        catalogAll = self.catalogShotPriority.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogShotStatus(self):

        listFromCatalog = []

        catalogAll = self.catalogShotStatus.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskComplex(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskComplex.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskEntity(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskEntity.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskName(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskName.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskPipelineStep(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskPipelineStep.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskPriority(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskPriority.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getCatalogTaskStatus(self):

        listFromCatalog = []

        catalogAll = self.catalogTaskStatus.readAll()

        for catalog in catalogAll:
            listFromCatalog.append(catalog.getTag())

        return listFromCatalog

    def getSgStepsDic(self):

        sgFields = ['id', 'code']
        dictionaryList = self.sg.find('Step', [], sgFields)

        stepDic = {}

        for dictionary in dictionaryList:
            stepDic.update({dictionary['code']: dictionary['id']})

        return stepDic

    def daoitem2sgDic(self, itemId):

        entity = self.itemInstance.readOneByProperties(
            self.itemInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Asset', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None

    def daoShot2sgDic(self, itemId):

        entity = self.shotInstance.readOneByProperties(
            self.shotInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Shot', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None

    def daoSequence2sgDic(self, itemId):

        entity = self.sequenceInstance.readOneByProperties(
            self.sequenceInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Sequence', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None

    def daoDM2sgDic(self, itemId):

        entity = self.dmInstance.readOneByProperties(
            self.dmInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Version', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None

    def daoHumanUser2sgDic(self, itemId):

        entity = self.userInstance.readOneByProperties(
            self.userInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Asset', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None

    def daoTask2sgDic(self, itemId):

        entity = self.taskInstance.readOneByProperties(
            self.taskInstance.Properties.Id, itemId)
        sgDic = {}

        if entity:
            if not entity.getShotgunID() == 0:

                sgDic = {'type': 'Task', 'id': entity.getShotgunID()}

                return sgDic

            else:
                return None

        else:
            return None
Esempio n. 4
0
class ShotgunUtils():
    '''
    this module is a collection of functions to conect the Asset manager to shogun studio website, to update, create
    and manages all attributes and parameters from the different entities.
    '''

    def __init__(self):
        '''
        creates the connection to the server and connects to database.
        creates list of Ids form the  database collections that needs to convert to shotgun collections

        '''

        SERVER_PATH = "https://hcpstudio.shotgunstudio.com"
        SCRIPT_NAME = 'sgApi'
        SCRIPT_KEY = '3899a8466f2cea694c2ba5341d871da845509d18d96a4feb7fb8d147de0fa819'

        self.sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)

        self.dbObjectID = ObjectId()

        master = DaoMaster()
        session = DaoMaster.getSession()

        self.itemInstance = session.getItemsDao()

        self.ItemStatusList = ['rdy', 'ip', 'app', 'crnt', 'outd','dep', 'vari', 'rej']

        self.ItemType = ['Source', 'Prop', 'Environment', 'Character', 'Rig', 'Fx', 'Template', 'Geometry', 'Art',
                         'Shader', 'Texture', 'Cache', 'ImageSequence', 'DCC', 'None']

        self.ItemClass = ['Item', 'Asset', 'superAsset']

    def getParameterSchema(self, fieldType, fieldName = None):
        '''
         utility function to search fields in a given entity.
        :param fieldType: entity to search parameters 'Project', 'Sequence', 'Shot', 'Asset', 'Version', etc.
        :param fieldName: name of the field to search 'id', 'name', 'coce', etc.
        :return: retruns a dictionary with the properties of given parameter
        '''

        squemaDic = self.sg.schema_field_read(fieldType, fieldName)
        print squemaDic
        for field in squemaDic:
            print field
        return squemaDic

    def getEntities(self):
        '''
        utility function to find all the Entities in shotgun for developing
        :return: renturn a list of all entities
        '''
        squemaDic = self.sg.schema_entity_read()
        for entity in squemaDic:
            print entity
        return squemaDic


    def createProject(self, sgName, sgStatus, sgType):
        ''' creates a Project using the given name, status, type,start date, end date.
            the status parameter is a list::
                Bidding
                Active
                Lost
                Hold

            the type parameter is a list:
                Feature
                Episodic
                Commercial
                Game Cinematic
                AAA Game
                Mobile Game
                Audio
                Mocap
                Misc
        '''
        data = {'name': sgName, 'sg_status': 'Active', 'sg_type': 'Feature'}
        fields = ['id']
        project = self.sg.create('Project', data, fields)
        return project

    def createSequence(self, projectID, sqName):
        '''
        creates a Sequence for the project set by the Id,
        :return: a dictionary containing the basic info of the sequence
        '''

        data = {'project': {'type': 'Project', 'id': projectID},
            'code': sqName}
        fields = ['id']
        sequence = self.sg.create('Sequence', data, fields)
        print sequence
        return sequence

    def createShot(self, projectID, shotName, sqID):

        data = {'project': {'type': 'Project', 'id': projectID},
            'code': shotName, 'sg_sequence': {'type': 'Sequence', 'id': sqID}}

        fields = ['id']
        shot = self.sg.create('Shot', data, fields)
        print shot
        return shot

    def createItem(self, projectID, itemName, itemType):
        '''
        creates an Item from an existing one inside the assetManager, use the parameters of given mongo objcet
        and updates the id of the mongo object with the shotgunId attribute of the mongo object.
        :return: a dictionary with the parameters defined in shotgun
        '''

        data = {'project': {'type': 'Project', 'id': projectID},
            'code': itemName, 'sg_asset_type': itemType}

        fields = ['id']
        item = self.sg.create('Asset', data, fields)
        print item
        return item

    def createDigitalMedia(self, projectID, dmName, dmType, taskID, entityType, entityID):

        data = {'project': {'type': 'Project', 'id': projectID},
            'code': dmName, 'sg_version_type': dmType, 'sg_task': {'type': 'Task', 'id': taskID},
            'entity': {'type': entityType, 'id': entityID}
                }

        fields = ['id']
        dm = self.sg.create('Version', data, fields)
        print dm
        return dm

    def createUser(self, firstName, lastName, userMail):

        data = {'firstname': firstName, 'lastname': lastName, 'email': userMail,
                'sg_status_list': 'dis', 'login': '******'.format(firstName,lastName)}
        fields = ['id']
        user = self.sg.create('HumanUser', data, fields)
        print user
        return user


    def createTask(self, projectID, entityType, entityID, taskName):
        data = {'project': {'type': 'Project', 'id': projectID},
                'task_assignees': [{'type': 'HumanUser', 'id': 86, 'name': 'Huevo Cartoon'}],
                'content': taskName, 'entity': {'type': entityType, 'id': entityID}
                }

        fields = ['id']
        task = self.sg.create('Task', data, fields)
        print task
        return task