Statistics
| Branch: | Tag: | Revision:

root / snf-astakos-app / astakos / scripts / upgrade / delete_astakos_users.py @ 50f74340

History | View | Annotate | Download (901 Bytes)

1
#!/usr/bin/env python
2

    
3
import os
4
import sys
5
from time import sleep
6

    
7
os.environ['DJANGO_SETTINGS_MODULE'] = 'synnefo.settings'
8

    
9
import astakos
10
from astakos.im.models import AstakosUser as A
11

    
12

    
13
def user_filter(user):
14
    return A.objects.filter(email__iexact=user.email).count() > 1
15

    
16
argv = sys.argv
17
argc = len(sys.argv)
18

    
19
if argc < 2:
20
    print "Usage: ./delete_astakos_users.py <id>..."
21
    raise SystemExit()
22

    
23
id_list = [int(x) for x in argv[1:]]
24

    
25
print ""
26
print "This will permanently delete the following users:\n"
27
print "id: email"
28
print "--  -----"
29

    
30
users = A.objects.filter(id__in=id_list)
31
for user in users:
32
    print "%s: %s" % (user.id, user.email)
33

    
34
print "\nExecute? (yes/no): ",
35
line = raw_input().rstrip()
36
if line != 'yes':
37
    print "\nCancelled"
38
    raise SystemExit()
39

    
40
print "\nConfirmed."
41
sleep(2)
42
for user in users:
43
    print "deleting %s: %s" % (user.id, user.email)
44
    user.delete()