2016-05-21 23:57:36 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
|
|
|
|
|
|
|
from gestioncof.models import Clipper
|
|
|
|
current = {}
|
|
|
|
print "[ FETCHING ]"
|
|
|
|
for clipper in Clipper.objects.all():
|
|
|
|
current[clipper.username] = clipper
|
|
|
|
print "[ SYNCING ]"
|
|
|
|
for line in sys.stdin:
|
|
|
|
bits = line.split(":")
|
|
|
|
username = bits[0]
|
|
|
|
fullname = bits[4]
|
|
|
|
if username in current:
|
|
|
|
clipper = current[username]
|
|
|
|
if clipper.fullname != fullname:
|
|
|
|
clipper.fullname = fullname
|
|
|
|
clipper.save()
|
|
|
|
print "Updated", username
|
|
|
|
else:
|
2016-07-09 21:19:37 +02:00
|
|
|
clipper = Clipper(username=username, fullname=fullname)
|
2016-05-21 23:57:36 +02:00
|
|
|
clipper.save()
|
|
|
|
print "Created", username
|
|
|
|
print "[ DONE ]"
|