2016-05-21 23:57:36 +02:00
|
|
|
#!/usr/bin/env python
|
2016-07-15 00:02:56 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-05-26 22:44:10 +02:00
|
|
|
|
2016-07-15 00:02:56 +02:00
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
2016-05-26 22:44:10 +02:00
|
|
|
|
2016-05-21 23:57:36 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2017-02-09 21:04:32 +01:00
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gestioCOF.settings")
|
2016-05-21 23:57:36 +02:00
|
|
|
|
2017-02-09 21:04:32 +01:00
|
|
|
from cof.models import Clipper
|
2016-05-21 23:57:36 +02:00
|
|
|
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 ]")
|