# Path: groups/models.py
# def group_uri2id( group_uri ):
# def group_id2uri( group_id ):
# def create_group( address, description, sequence ):
# def _group2json(group_db):
# def get_group( group_uri ):
# def get_groups( sequence=None ):
# def get_member_groups( member_email ):
# def add_group_member( group_uri, member_email ):
# def remove_group_member( group_uri, member_email ):
# def sync_group_with_mailgun( group_uri ):


from models import get_bios_by_email
from groups import models as group_model
from PIL import Image
from boto.s3.key import Key
from django.conf import settings
import requests
import math
import boto



def combine_photos(bios, width=6, avatar_size=(120,120)):
    # download images and sticth them together
    images = []
    for bio in bios:
        try:
            resp = requests.get(bio['avatar'], stream=True)
            with open('/tmp/' + bio['email'], 'wb') as f:
                for chunk in resp.iter_content(chunk_size=1024): 
                    if chunk: # filter out keep-alive new chunks
                        f.write(chunk)
                        f.flush()
            images += [ '/tmp/' + bio['email'] ]

# Path: groups/models.py
# def group_uri2id( group_uri ):
# def group_id2uri( group_id ):
# def create_group( address, description, sequence ):
# def _group2json(group_db):
# def get_group( group_uri ):
# def get_groups( sequence=None ):
# def get_member_groups( member_email ):
# def add_group_member( group_uri, member_email ):
# def remove_group_member( group_uri, member_email ):
# def sync_group_with_mailgun( group_uri ):


# Path: classphoto/group_photo.py
from models import get_bios_by_email
from groups import models as group_model
from PIL import Image
from boto.s3.key import Key
from django.conf import settings
import requests
import math
import boto




def combine_photos(bios, width=6, avatar_size=(120,120)):
    # download images and sticth them together
    images = []
    for bio in bios:
        try:
            resp = requests.get(bio['avatar'], stream=True)
            with open('/tmp/' + bio['email'], 'wb') as f:
                for chunk in resp.iter_content(chunk_size=1024): 
                    if chunk: # filter out keep-alive new chunks
                        f.write(chunk)
                        f.flush()
            images += [ '/tmp/' + bio['email'] ]

        except Exception as e: