misc: use print as a function
This commit is contained in:
parent
537f9125cd
commit
f35458c2fc
|
@ -14,6 +14,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
|
@ -52,7 +54,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
for account in OIDCAccount.objects.filter(sub__in=unknown_uuids):
|
for account in OIDCAccount.objects.filter(sub__in=unknown_uuids):
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'disabling', account.user.email, account.user.ou
|
print('disabling', account.user.email, account.user.ou)
|
||||||
account.user.email = account.user.email + '.invalid'
|
account.user.email = account.user.email + '.invalid'
|
||||||
account.user.save()
|
account.user.save()
|
||||||
OIDCAccount.objects.filter(sub__in=unknown_uuids).delete()
|
OIDCAccount.objects.filter(sub__in=unknown_uuids).delete()
|
||||||
|
@ -95,7 +97,7 @@ class Command(BaseCommand):
|
||||||
user = User.objects.get(email=cut_user_data['email'], ou=ou_gnm)
|
user = User.objects.get(email=cut_user_data['email'], ou=ou_gnm)
|
||||||
except User.MultipleObjectsReturned:
|
except User.MultipleObjectsReturned:
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'bad duplicated email', cut_user_data['email']
|
print('bad duplicated email', cut_user_data['email'])
|
||||||
continue
|
continue
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
# uuid?
|
# uuid?
|
||||||
|
@ -104,7 +106,7 @@ class Command(BaseCommand):
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
# at last, create new user
|
# at last, create new user
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'creating', cut_user_data['email']
|
print('creating', cut_user_data['email'])
|
||||||
user = User()
|
user = User()
|
||||||
|
|
||||||
if (user.uuid != cut_user_data['sub'] or
|
if (user.uuid != cut_user_data['sub'] or
|
||||||
|
@ -113,7 +115,7 @@ class Command(BaseCommand):
|
||||||
user.first_name != cut_user_data['first_name'] or
|
user.first_name != cut_user_data['first_name'] or
|
||||||
user.last_name != cut_user_data['last_name']):
|
user.last_name != cut_user_data['last_name']):
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'updating', user.email, '->', ou_gnm
|
print('updating', user.email, '->', ou_gnm)
|
||||||
# only touch user if there are changes
|
# only touch user if there are changes
|
||||||
user.uuid = cut_user_data['sub']
|
user.uuid = cut_user_data['sub']
|
||||||
user.ou = ou_gnm
|
user.ou = ou_gnm
|
||||||
|
@ -126,4 +128,4 @@ class Command(BaseCommand):
|
||||||
OIDCAccount.objects.get_or_create(provider=cut_agents, user=user, sub=cut_user_data['sub'])
|
OIDCAccount.objects.get_or_create(provider=cut_agents, user=user, sub=cut_user_data['sub'])
|
||||||
except django.db.utils.IntegrityError:
|
except django.db.utils.IntegrityError:
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'oops duplicated email?', cut_user_data['email']
|
print('oops duplicated email?', cut_user_data['email'])
|
||||||
|
|
Reference in New Issue