<commit_before>from urllib2 import urlopen, HTTPError
from image.models import Image
from django.template.defaultfilters import slugify
from django.core.files.base import ContentFile
from utils import make_social_username, get_domain_from_url


def save_avatar(strategy, user, response, details, is_new=False,*args,**kwargs):

    if is_new or not user.image:
        
        img = None

        # FACEBOOK
        if strategy.backend.name == 'facebook':  
			try:
				img_url = "http://graph.facebook.com/{id}/picture?type=large".format(id=response["id"])
				img = urlopen(img_url)
				suffix = '_fb'
			except HTTPError:
				pass

		# TWITTER 
        if strategy.backend.name == 'twitter':
            try:
                deb = open('/tmp/debug_datea.txt', 'w')
                deb.write(response['profile_image_url'])
                deb.close()
                img = urlopen(response['profile_image_url'])
        		suffix = '_tw'
        	except HTTPError:
        		pass

        # GOOGLE
        if strategy.backend.name == 'google-oauth2':
        	try:
        		img = urlopen(response['picture'])
        		suffix = '_g'
        	except HTTPError:
        		pass

        if img:<commit_msg>debug attempt of twitter pic 4<commit_after>from urllib2 import urlopen, HTTPError
from image.models import Image
from django.template.defaultfilters import slugify
from django.core.files.base import ContentFile
from utils import make_social_username, get_domain_from_url


def save_avatar(strategy, user, response, details, is_new=False,*args,**kwargs):

    if is_new or not user.image:
        
        img = None

        # FACEBOOK
        if strategy.backend.name == 'facebook':  
			try:
				img_url = "http://graph.facebook.com/{id}/picture?type=large".format(id=response["id"])
				img = urlopen(img_url)
				suffix = '_fb'
			except HTTPError:
				pass

		# TWITTER 
        if strategy.backend.name == 'twitter':
            try:
                deb = open('/tmp/debug_datea.txt', 'w')
                deb.write(response['profile_image_url'])
                deb.close()
                img = urlopen(response['profile_image_url'])
                suffix = '_tw'
            except HTTPError:
                pass

        # GOOGLE
        if strategy.backend.name == 'google-oauth2':
        	try:
        		img = urlopen(response['picture'])
        		suffix = '_g'
        	except HTTPError:
        		pass

        if img:
{'fraction_non_alphanumeric': 0.10483210483210484, 'fraction_numerical': 0.0020475020475020475, 'mean_word_length': 2.1604139715394566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2995427', 'n_tokens_mistral': 784, 'n_tokens_neox': 726, 'n_words': 164}