Beispiel #1
0

def save_and_resize_image(user_name, file_name, local_name):
    img = Image.open(local_name)
    width, height = img.size
    ratio = float(height) / width

    rez = img.resize((IMAGE_WIDTH, (int(IMAGE_WIDTH * ratio))),
                     Image.ANTIALIAS)
    new_file_name = "media/thumbnails/" + str(user_name) + file_name.split(
        "/")[-1]
    rez.save(new_file_name, "JPEG")


while (True):
    users = [x for x in conn.get_all_users()]
    for user in users:
        access_token = user['access_token']
        if access_token is None:
            continue

        try:
            client = dropbox.client.DropboxClient(access_token)
            client.account_info()

        except dropbox.rest.ErrorResponse, e:
            print 'invalid dropbox access_token'
            continue

        delta = client.delta(user['cursor'])
        conn.update_cursor(user['_id'], delta['cursor'])
Beispiel #2
0
highest_group = conn.get_highest_group()


IMAGE_WIDTH = 350

def save_and_resize_image(user_name,file_name,local_name):
    img = Image.open(local_name)
    width, height = img.size
    ratio = float(height)/width
        
    rez = img.resize((IMAGE_WIDTH,(int(IMAGE_WIDTH*ratio))), Image.ANTIALIAS)
    new_file_name = "media/thumbnails/" + str(user_name) + file_name.split("/")[-1]
    rez.save(new_file_name,"JPEG")

while(True):
    users = [x for x in conn.get_all_users()]    
    for user in users:
         access_token = user['access_token']
         if access_token is None:
             continue
    
         try:
             client = dropbox.client.DropboxClient(access_token)
             client.account_info()

         except dropbox.rest.ErrorResponse, e:
             print 'invalid dropbox access_token'
             continue
    
         delta = client.delta(user['cursor'])
         conn.update_cursor(user['_id'], delta['cursor'])