<commit_before>from forum.models import MessageIcon
from django.core.exceptions import *
from glob import glob

def update_icons_db():
    for j in glob('forum/static/forum/icons/*.jpg') + glob('forum/static/forum/icons/*.gif'):
        i = j.split('/').pop() 
        try:
            MessageIcon.objects.get(filename=i)
        except ObjectDoesNotExist:
            MessageIcon(name=i, filename=i).save()
            print "fichier {} ajoute".format(i)
        except MultipleObjectsReturned:
            print "{} n'est pas unique".format(i)
            raise

update_icons_db()<commit_msg>prevents the update of the message icons filename from failing when there is no table (before migrations)<commit_after>from forum.models import MessageIcon
from django.core.exceptions import *
from glob import glob

def update_icons_db():
    for j in glob('forum/static/forum/icons/*.jpg') + glob('forum/static/forum/icons/*.gif'):
        i = j.split('/').pop() 
        try:
            MessageIcon.objects.get(filename=i)
        except ObjectDoesNotExist:
            MessageIcon(name=i, filename=i).save()
            print "fichier {} ajoute".format(i)
        except MultipleObjectsReturned:
            print "{} n'est pas unique".format(i)
        except:
            pass

update_icons_db()
{'fraction_non_alphanumeric': 0.11814671814671815, 'fraction_numerical': 0.0, 'mean_word_length': 2.7241379310344827, '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': '1952847', 'n_tokens_mistral': 381, 'n_tokens_neox': 367, 'n_words': 90}