Browse Source

fixed some. Added possibility to import mailboxes from zayavka to ics

master
Mikhail Grebenkin 2 years ago
parent
commit
9d4568ca2b
3 changed files with 34 additions and 14 deletions
  1. +4
    -4
      UserAd_class.py
  2. +5
    -0
      crontab
  3. +25
    -10
      zayavka_reader.py

+ 4
- 4
UserAd_class.py View File

@ -146,12 +146,12 @@ def main():
lp.load(samba.param.default_path()) # или lp.load("/etc/samba/smb.conf") lp.load(samba.param.default_path()) # или lp.load("/etc/samba/smb.conf")
sam = SamDB(lp=lp, session_info=system_session()) sam = SamDB(lp=lp, session_info=system_session())
test_usr = UserAd(sam, base, domainName, 'tst', "secret34daD") test_usr = UserAd(sam, base, domainName, 'tst', "secret34daD")
print test_usr.memberOf
print "Set disable error: ", test_usr.disable()
print(test_usr.memberOf)
print("Set disable error: ", test_usr.disable())
time.sleep(1) time.sleep(1)
print "Set enable error: ", test_usr.enable()
print("Set enable error: ", test_usr.enable())
time.sleep(1) time.sleep(1)
print "Set remove error: ", test_usr.remove()
print("Set remove error: ", test_usr.remove())
if __name__ == '__main__': if __name__ == '__main__':


+ 5
- 0
crontab View File

@ -0,0 +1,5 @@
7 * * * * root /opt/zayavka-samba-ad/zayavka_reader.py /tmp/mailboxes.csv && scp /tmp/mailboxes.csv 10.2.2.13:/tmp/ && ssh 10.2.2.13 'php -f /root/importMailBoxes.php /tmp/mailboxes.csv'
37 * * * * root /opt/zayavka-samba-ad/zayavka_reader.py /tmp/mailboxes.csv && scp /tmp/mailboxes.csv 10.2.2.13:/tmp/ && ssh 10.2.2.13 'php -f /root/importMailBoxes.php /tmp/mailboxes.csv'
2 * * * * root /opt/zayavka_samba_ad/importer.py
32 * * * * root /opt/zayavka_samba_ad/importer.py

+ 25
- 10
zayavka_reader.py View File

@ -1,9 +1,11 @@
#!/usr/bin/python2
#!/usr/bin/python3
# coding=utf-8 # coding=utf-8
import csv
import sys
import MySQLdb import MySQLdb
dbconn = {'host': '10.3.11.177',
dbconn = {'host': '10.3.11.226',
'user': 'readonlyuser', 'user': 'readonlyuser',
'pass': 'Readonly@2006', 'pass': 'Readonly@2006',
'base': 'techgrow'} 'base': 'techgrow'}
@ -80,18 +82,31 @@ def users_make_zayavka(users):
return res 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(): def main():
data, err = mysql_reader(dbconn, sql) 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: 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__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save

Powered by TurnKey Linux.