Skip to content

Commit

Permalink
Ensure settings path exists and create if not (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim020 committed Jan 29, 2023
1 parent fc34469 commit b3b9231
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,22 @@ def __init__(self, application: DigiScriptServer, settings_path=None):
self._application = application
self.lock = Lock()
self._base_path = os.path.join(os.path.dirname(__file__), '..', 'conf')

if not os.path.exists(self._base_path):
get_logger().info(f'Creating base path {self._base_path}')
os.makedirs(self._base_path)

if settings_path:
self.settings_path = settings_path
else:
self.settings_path = os.path.join(self._base_path, 'digiscript.json')
get_logger().info(
f'No settings path provided, using {self.settings_path}')

if not os.path.exists(os.path.dirname(self.settings_path)):
get_logger().info(f'Creating settings path {os.path.dirname(self.settings_path)}')
os.makedirs(os.path.dirname(self.settings_path))

self.settings = {}

self.define('current_show', int, None, False, nullable=True)
Expand Down

0 comments on commit b3b9231

Please sign in to comment.