dump_webapp_signatures.py: Add exception when trying to retrieve webapp settings.
This commit is contained in:
parent
67bd0abfa4
commit
2c4b08cf73
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import kopano
|
import kopano
|
||||||
import sys
|
|
||||||
from MAPI.Util import *
|
from MAPI.Util import *
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -21,16 +20,19 @@ def main():
|
|||||||
print 'Please use:\n %s --user <username>' % (sys.argv[0])
|
print 'Please use:\n %s --user <username>' % (sys.argv[0])
|
||||||
else:
|
else:
|
||||||
user = kopano.Server(options=options).user(options.user)
|
user = kopano.Server(options=options).user(options.user)
|
||||||
settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
|
try:
|
||||||
if len(settings['settings']['zarafa']['v1']['contexts']['mail']):
|
settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
|
||||||
if 'signatures' in settings['settings']['zarafa']['v1']['contexts']['mail']:
|
except Exception as e:
|
||||||
for item in settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all']:
|
print 'Could not load WebApp settings for user %s (Error: %s)' % (user.name, repr(e))
|
||||||
name = settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['name']
|
else:
|
||||||
filename = '%s-%s-%s.html' % (user.name, name.replace(' ', '-'), item)
|
if len(settings['settings']['zarafa']['v1']['contexts']['mail']):
|
||||||
print 'Dumping: \'%s\' to \'%s\' ' % (name, filename)
|
if 'signatures' in settings['settings']['zarafa']['v1']['contexts']['mail']:
|
||||||
with open(filename, 'w') as outfile:
|
for item in settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all']:
|
||||||
outfile.write(settings['settings']['zarafa']['v1']['contexts']['mail']['signatures']['all'][item]['content'].encode('utf-8'))
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
x
Reference in New Issue
Block a user