|
|
@ -1,9 +1,11 @@ |
|
|
|
#!/usr/bin/python2 |
|
|
|
#!/usr/bin/python3 |
|
|
|
# coding=utf-8 |
|
|
|
import csv |
|
|
|
import sys |
|
|
|
|
|
|
|
import MySQLdb |
|
|
|
|
|
|
|
dbconn = {'host': '10.3.11.177', |
|
|
|
dbconn = {'host': '10.3.11.226', |
|
|
|
'user': 'readonlyuser', |
|
|
|
'pass': 'Readonly@2006', |
|
|
|
'base': 'techgrow'} |
|
|
@ -80,18 +82,31 @@ def users_make_zayavka(users): |
|
|
|
|
|
|
|
return res |
|
|
|
|
|
|
|
def mailboxes(data): |
|
|
|
mboxes = [] |
|
|
|
for user in data: |
|
|
|
domain = user['LoginEmail'].split('@')[1] |
|
|
|
name = user['LoginEmail'].split('@')[0] |
|
|
|
mbox = ["Администратор", domain, name, user['Pass'], user['Changes'], user['Delete']] |
|
|
|
mboxes.append(mbox) |
|
|
|
return mboxes |
|
|
|
|
|
|
|
def main(): |
|
|
|
data, err = mysql_reader(dbconn, sql) |
|
|
|
if not err: |
|
|
|
users = users_make_zayavka(data) |
|
|
|
x = '' |
|
|
|
for user in users: |
|
|
|
print(user, users[user]) |
|
|
|
input(x) |
|
|
|
if len(sys.argv) == 1: |
|
|
|
if not err: |
|
|
|
users = users_make_zayavka(data) |
|
|
|
x = '' |
|
|
|
for user in users: |
|
|
|
print(user, users[user]) |
|
|
|
input(x) |
|
|
|
else: |
|
|
|
print(err) |
|
|
|
else: |
|
|
|
print(err) |
|
|
|
|
|
|
|
csvFile = sys.argv[1]; |
|
|
|
with open(csvFile, 'w') as f: |
|
|
|
write = csv.writer(f, quoting=csv.QUOTE_ALL) |
|
|
|
write.writerows(mailboxes(data)) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
main() |