fix(#402): fix config files cannot be written if copied from /nix/store (#403)

This commit is contained in:
Serhii Khoma 2020-12-20 16:25:30 +02:00 committed by GitHub
parent a29d027852
commit 4939d1ff6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -377,6 +377,7 @@ def initialize_safeeyes():
# Copy the safeeyes.json
shutil.copy2(SYSTEM_CONFIG_FILE_PATH, CONFIG_FILE_PATH)
os.chmod(CONFIG_FILE_PATH, 0o777)
# Copy the new startup file
try:
@ -388,6 +389,7 @@ def initialize_safeeyes():
# Copy the new style sheet
if not os.path.isfile(STYLE_SHEET_PATH):
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
os.chmod(STYLE_SHEET_PATH, 0o777)
def reset_config():
@ -398,6 +400,10 @@ def reset_config():
# Copy the safeeyes.json and safeeyes_style.css
shutil.copy2(SYSTEM_CONFIG_FILE_PATH, CONFIG_FILE_PATH)
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
# Add write permission (e.g. if original file was stored in /nix/store)
os.chmod(CONFIG_FILE_PATH, 0o777)
os.chmod(STYLE_SHEET_PATH, 0o777)
def replace_style_sheet():
"""
@ -405,6 +411,7 @@ def replace_style_sheet():
"""
delete(STYLE_SHEET_PATH)
shutil.copy2(SYSTEM_STYLE_SHEET_PATH, STYLE_SHEET_PATH)
os.chmod(STYLE_SHEET_PATH, 0o777)
def intialize_logging(debug):
@ -591,4 +598,4 @@ def remove_if_exists(list_of_items, item):
Remove the item from the list_of_items it it exists.
"""
if item in list_of_items:
list_of_items.remove(item)
list_of_items.remove(item)