webapp-tools/webapp_switch_locale/webapp_switch_locale.py

36 lines
1.0 KiB
Python
Raw Normal View History

2016-11-10 11:29:45 +01:00
#!/usr/bin/env python
# encoding: utf-8
import json
import kopano
from MAPI.Util import *
import sys
def opt_args():
parser = kopano.parser('skpcfm')
parser.add_option("--user", dest="user", action="store", help="Run script for user")
parser.add_option("--locale", dest="locale", action="store", help="Set new locale")
return parser.parse_args()
def main():
options, args = opt_args()
if not options.user:
print 'Please use:\n %s --user <username> [--locale]' % (sys.argv[0])
sys.exit()
user = kopano.Server(options).user(options.user)
settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
current = settings['settings']['zarafa']['v1']['main']['language']
print 'Original locale: %s' % current
if options.locale:
print 'Setting locale to: %s' % options.locale
settings['settings']['zarafa']['v1']['main']['language'] = options.locale
user.store.create_prop(PR_EC_WEBACCESS_SETTINGS_JSON, json.dumps(settings))
2016-11-10 11:29:45 +01:00
if __name__ == "__main__":
main()