Updated the init process to get the branch from package_info in docker images

pull/1358/head
morpheus65535 4 years ago
parent e88c94ccd2
commit 0c09bc2360

@ -92,8 +92,30 @@ with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle
# migrate enabled_providers from comma separated string to list # migrate enabled_providers from comma separated string to list
if isinstance(settings.general.enabled_providers, str) and not settings.general.enabled_providers.startswith('['): if isinstance(settings.general.enabled_providers, str) and not settings.general.enabled_providers.startswith('['):
settings.general.enabled_providers = str(settings.general.enabled_providers.split(",")) settings.general.enabled_providers = str(settings.general.enabled_providers.split(","))
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle) settings.write(handle)
# make sure settings.general.branch is properly set when running inside a docker container
package_info_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'package_info')
if os.path.isfile(package_info_file):
try:
package_info = {}
with open(package_info_file) as file:
for line in file.readlines():
if line == '\n':
break
splitted_line = line.split('=')
if len(splitted_line) == 2:
package_info[splitted_line[0].lower()] = splitted_line[1].replace('\n', '')
else:
continue
if 'branch' in package_info:
settings.general.branch = package_info['branch']
except:
pass
else:
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
# create database file # create database file
if not os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')): if not os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')):

Loading…
Cancel
Save