#find all the users that have skype-id's
users= sg.find("HumanUser",filters,fields)

#initialize an empty list to contain shotgun update requests
batch_data = []

#process all users checking to see if button data is correct for the user name
# (this is in case a skype user name changes) or if there is not a button
for user in users:
    # put skype user name into template to create button html code
    skype_button_text = button_template.safe_substitute(skype_id=user[SKYPE_ID_FIELD])
    skype_contact_text = contact_template.safe_substitute(skype_id=user[SKYPE_ID_FIELD])
    
    if user[SKYPE_BUTTON_FIELD] <> skype_button_text:
        #set the skype button html into the user container
        user[SKYPE_BUTTON_FIELD] = skype_button_text
        user[SKYPE_ADD_CONTACT_FIELD] = skype_contact_text
        
        #remove extraneous data from user so that it can put into an update request 
        user_id = user.pop('id')
        dummy = user.pop('type')
        
        #append the update to the batch list
        batch_data.append( {'request_type':'update' , 'entity_type':'HumanUser' , 'entity_id': user_id , 'data':user})

# when done, process the updates to the users with a single call to shotgun (if necessary)
if batch_data:
    sg.batch(batch_data)
    
    
Пример #2
0
#process all users checking to see if button data is correct for the user name
# (this is in case a skype user name changes) or if there is not a button
for user in users:
    # put skype user name into template to create button html code
    skype_button_text = button_template.safe_substitute(
        skype_id=user[SKYPE_ID_FIELD])
    skype_contact_text = contact_template.safe_substitute(
        skype_id=user[SKYPE_ID_FIELD])

    if user[SKYPE_BUTTON_FIELD] <> skype_button_text:
        #set the skype button html into the user container
        user[SKYPE_BUTTON_FIELD] = skype_button_text
        user[SKYPE_ADD_CONTACT_FIELD] = skype_contact_text

        #remove extraneous data from user so that it can put into an update request
        user_id = user.pop('id')
        dummy = user.pop('type')

        #append the update to the batch list
        batch_data.append({
            'request_type': 'update',
            'entity_type': 'HumanUser',
            'entity_id': user_id,
            'data': user
        })

# when done, process the updates to the users with a single call to shotgun (if necessary)
if batch_data:
    sg.batch(batch_data)
Пример #3
0
WEEKEND = 65

date = datetime.date.today()
batchData = []
for i in range(1, 366):
    dayType = WEEKDAY if date.weekday() in range(0, 5) else WEEKEND
    batchData.append({
        'request_type': 'create',
        'entity_type': 'CustomEntity15',
        'data': {
            'project': {
                'type': 'Project',
                'id': 70
            },
            'sg_story_day': date.strftime("%Y-%m-%d"),
            'sg_status_list': 'wtg',
            'task_template': {
                'type': "TaskTemplate",
                'id': dayType
            }
        }
    })
    date += datetime.timedelta(days=1)

pp(batchData)
sg = Shotgun('', '', '')
sg.batch(batchData)

#pp(date.strftime("%Y-%m-%d"))
#date += datetime.timedelta(days=1)
#pp(date.strftime("%Y-%m-%d"))