check for read-only filesystem and exit if write needed and cannot. Fixes #146

This commit is contained in:
Nicholas St. Germain 2019-08-09 17:06:41 -05:00
parent 378e8d6401
commit cca283d657
No known key found for this signature in database
GPG key ID: 291EE25B239FA5EE
2 changed files with 4 additions and 126 deletions

View file

@ -1,3 +1,4 @@
from os import W_OK, access
from shutil import copyfile
from os import environ as env
from logging import getLogger
@ -77,6 +78,9 @@ class INIParser(object):
file_path = join(self.data_folder, ini)
if exists(file_path):
self.logger.debug('Writing to %s', inifile)
if not access(file_path, W_OK):
self.logger.error("Config file is incomplete and read-only. Exiting.")
exit(1)
with open(file_path, 'w') as config_ini:
self.config.write(config_ini)
else: