support lists/tuples in 'serverwebroot' config item

This allows the user to specify multiple servers to put the repo to, and
`fdroid server update` will automatically push to them all.

fixes #22 https://gitlab.com/fdroid/fdroidserver/issues/22
This commit is contained in:
Hans-Christoph Steiner 2014-07-14 15:03:58 -04:00
parent 35ee4b1bc5
commit 8c8fb8b156
3 changed files with 32 additions and 18 deletions

View file

@ -168,12 +168,21 @@ def read_config(opts, config_file='config.py'):
if k in config:
config[k] = clean_description(config[k])
# since this is used with rsync, where trailing slashes have meaning,
# ensure there is always a trailing slash
if 'serverwebroot' in config:
if config['serverwebroot'][-1] != '/':
config['serverwebroot'] += '/'
config['serverwebroot'] = config['serverwebroot'].replace('//', '/')
if isinstance(config['serverwebroot'], basestring):
roots = [config['serverwebroot']]
elif all(isinstance(item, basestring) for item in config['serverwebroot']):
roots = config['serverwebroot']
else:
raise TypeError('only accepts strings, lists, and tuples')
rootlist = []
for rootstr in roots:
# since this is used with rsync, where trailing slashes have
# meaning, ensure there is always a trailing slash
if rootstr[-1] != '/':
rootstr += '/'
rootlist.append(rootstr.replace('//', '/'))
config['serverwebroot'] = rootlist
return config