From f2e65d9e9d6fb673000b872d8650ca2b94752089 Mon Sep 17 00:00:00 2001 From: Andres Torres <34612646+Ahsoka@users.noreply.github.com> Date: Thu, 8 Jul 2021 19:59:29 -0700 Subject: [PATCH] Fixed settings.py to support Linux --- beskar/settings.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/beskar/settings.py b/beskar/settings.py index 2dfe14d..b18ec46 100644 --- a/beskar/settings.py +++ b/beskar/settings.py @@ -5,19 +5,21 @@ import json import os -location = None -try: - location = os.environ['PROGRAMDATA'] -except KeyError: - location = None -if not location: - location = r'C:\ProgramData' - sentinel = object() class Settings: - def __init__(self, location: Union[str, Literal[r'C:\Program Data']] = location): - self.settings_path = pathlib.Path(location) / 'Beskar' / 'settings.json' + def __init__(self, location: Union[str, Literal[r'C:\Program Data']] = None): + if os.name == 'nt': + if location is None: + try: + location = os.environ['PROGRAMDATA'] + except KeyError: + location = None + if not location: + location = r'C:\ProgramData' + self.settings_path = pathlib.Path(location) / 'Beskar' / 'settings.json' + else: + self.settings_path = pathlib.Path('settings.json') if self.settings_path.exists(): file_healthy = True with self.settings_path.open() as file: