2016-05-21 23:57:36 +02:00
|
|
|
#!/usr/bin/env python
|
2016-05-26 22:44:10 +02:00
|
|
|
|
|
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
|
2016-05-21 23:57:36 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
|
|
|
|
|
|
|
from gestioncof.models import Clipper
|
|
|
|
current = {}
|
2016-05-26 22:44:10 +02:00
|
|
|
print("[ FETCHING ]")
|
2016-05-21 23:57:36 +02:00
|
|
|
for clipper in Clipper.objects.all():
|
|
|
|
current[clipper.username] = clipper
|
2016-05-26 22:44:10 +02:00
|
|
|
print("[ SYNCING ]")
|
2016-05-21 23:57:36 +02:00
|
|
|
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()
|
2016-05-26 22:44:10 +02:00
|
|
|
print("Updated", username)
|
2016-05-21 23:57:36 +02:00
|
|
|
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()
|
2016-05-26 22:44:10 +02:00
|
|
|
print("Created", username)
|
|
|
|
print("[ DONE ]")
|