add webappsetting and renamed remove_recipients
This commit is contained in:
parent
7aaed68ad6
commit
976fbac1dd
30
readme.md
30
readme.md
@ -1,4 +1,4 @@
|
|||||||
remove-recipients.py
|
remove_recipients.py
|
||||||
====================
|
====================
|
||||||
Remove recipients in webapp
|
Remove recipients in webapp
|
||||||
|
|
||||||
@ -8,19 +8,19 @@ Remove recipients in webapp
|
|||||||
###### List recipients
|
###### List recipients
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python remove-recipients.py --user <user> --list
|
python remove_recipients.py --user <user> --list
|
||||||
```
|
```
|
||||||
###### Remove recipient
|
###### Remove recipient
|
||||||
Remove options is searching in display_name, smtp_address or email_address.
|
Remove options is searching in display_name, smtp_address or email_address.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python remove-recipients.py --user <user> --remove <recipient name>
|
python remove_recipients.py --user <user> --remove <recipient name>
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Clear history
|
###### Clear history
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python remove-recipients.py --user <user> --remove-all
|
python remove_recipients.py --user <user> --remove-all
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
@ -28,5 +28,25 @@ python remove-recipients.py --user <user> --remove-all
|
|||||||
Remove all recipients that have example.com in there display_name, smtp_address or email_address
|
Remove all recipients that have example.com in there display_name, smtp_address or email_address
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python remove-recipients.py --user user --remove example.com
|
python remove_recipients.py --user user --remove example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
webapp_settings.py
|
||||||
|
==================
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
|
||||||
|
|
||||||
|
###### Backup
|
||||||
|
|
||||||
|
```python
|
||||||
|
python webapp_settings.py --user user --backup
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
###### Restore
|
||||||
|
|
||||||
|
```python
|
||||||
|
python webapp_settings.py --user user --restore
|
||||||
```
|
```
|
45
webapp_settings.py
Normal file
45
webapp_settings.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from MAPI import *
|
||||||
|
from MAPI.Util import *
|
||||||
|
import sys
|
||||||
|
import kopano
|
||||||
|
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
import simplejson as json
|
||||||
|
|
||||||
|
def opt_args():
|
||||||
|
parser = kopano.parser('skpcfm')
|
||||||
|
parser.add_option("--user", dest="user", action="store", help="Run script for user")
|
||||||
|
parser.add_option("--backup", dest="backup", action="store_true", help="Backup webapp setting ")
|
||||||
|
parser.add_option("--restore", dest="restore", action="store_true", help="Restore webapp settings")
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
options, args = opt_args()
|
||||||
|
|
||||||
|
if not options.user or (not options.backup and not options.restore):
|
||||||
|
print 'Please use:\n %s --user <username> (--backup or --restore) ' % (sys.argv[0])
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
user = kopano.Server(options).user(options.user)
|
||||||
|
if options.backup:
|
||||||
|
webapp = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
|
||||||
|
f = open('%s.json' % user.name,'w')
|
||||||
|
|
||||||
|
f.write(json.dumps(webapp, sort_keys=True,
|
||||||
|
indent=4, separators=(',', ': ')))
|
||||||
|
f.close()
|
||||||
|
if options.restore:
|
||||||
|
with open('%s.json' % user.name) as data_file:
|
||||||
|
data = json.load(data_file)
|
||||||
|
|
||||||
|
print data
|
||||||
|
user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).set_value(json.dumps(data))
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user