Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4d8b0b77c9
38
dump_webapp_signatures.py
Normal file
38
dump_webapp_signatures.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
import kopano
|
||||
from MAPI.Util import *
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
|
||||
def opt_args():
|
||||
parser = kopano.parser('skpcf')
|
||||
parser.add_option("--user", dest="user", action="store", help="Dump signatures for user")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
options, args = opt_args()
|
||||
if not options.user:
|
||||
print 'Please use:\n %s --user <username>' % (sys.argv[0])
|
||||
else:
|
||||
user = kopano.Server(options=options).user(options.user)
|
||||
try:
|
||||
settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
|
||||
except Exception as e:
|
||||
print 'Could not load WebApp settings for user %s (Error: %s)' % (user.name, repr(e))
|
||||
else:
|
||||
if len(settings['settings']['zarafa']['v1']['contexts']['mail']):
|
||||
if 'signatures' in settings['settings']['zarafa']['v1']['contexts']['mail']:
|
||||
for item in settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all']:
|
||||
name = settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['name']
|
||||
filename = '%s-%s-%s.html' % (user.name, name.replace(' ', '-'), item)
|
||||
with open(filename, 'w') as outfile:
|
||||
print 'Dumping: \'%s\' to \'%s\' ' % (name, filename)
|
||||
outfile.write(settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['content'].encode('utf-8'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
10
readme.md
10
readme.md
@ -50,3 +50,13 @@ python webapp_settings.py --user user --backup
|
||||
```python
|
||||
python webapp_settings.py --user user --restore
|
||||
```
|
||||
|
||||
dump_webapp_signatures.py
|
||||
=========================
|
||||
Dumps all the signatures in a users Webapp to seperate files, meant as companion to the script setdefaultsignature.py as delivered with Webapp (see /usr/share/doc/kopano-webapp/scripts/signatures/ on your Webapp server.)
|
||||
The files will be written in the current directory.
|
||||
|
||||
#### Usage:
|
||||
```python
|
||||
python dump_webapp_signatures.py --user user
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user