- {% for key, value in main_config.display.display_durations.items() %}
+ {% for key, value in main_config.get('display', {}).get('display_durations', {}).items() %}
{{ key | replace('_', ' ') | title }}
diff --git a/update_pi_files.py b/update_pi_files.py
new file mode 100644
index 00000000..4926a9ad
--- /dev/null
+++ b/update_pi_files.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+"""
+Simple script to update files on the Pi
+"""
+import subprocess
+import sys
+
+def copy_file_to_pi(local_file, remote_path):
+ """Copy a file to the Pi using scp"""
+ try:
+ cmd = ['scp', local_file, f'ledpi@ledpi:{remote_path}']
+ result = subprocess.run(cmd, check=True, capture_output=True, text=True)
+ print(f"Successfully copied {local_file} to {remote_path}")
+ return True
+ except subprocess.CalledProcessError as e:
+ print(f"Error copying {local_file}: {e}")
+ print(f"stderr: {e.stderr}")
+ return False
+
+if __name__ == "__main__":
+ # Copy the updated web interface file
+ success1 = copy_file_to_pi('web_interface_v2.py', '/home/ledpi/LEDMatrix/')
+
+ # Copy the updated template file
+ success2 = copy_file_to_pi('templates/index_v2.html', '/home/ledpi/LEDMatrix/templates/')
+
+ if success1 and success2:
+ print("All files copied successfully!")
+ print("You can now restart the web interface on the Pi.")
+ else:
+ print("Some files failed to copy. Please check the errors above.")
+ sys.exit(1)
diff --git a/web_interface_v2.py b/web_interface_v2.py
index d896d59f..f839d35b 100644
--- a/web_interface_v2.py
+++ b/web_interface_v2.py
@@ -113,6 +113,9 @@ class DictWrapper:
def __bool__(self):
# Return False for empty wrappers
if hasattr(self, '_value'):
+ # Avoid recursion by checking if _value is a DictWrapper
+ if isinstance(self._value, DictWrapper):
+ return False # Empty DictWrapper is falsy
return bool(self._value)
return False
@@ -455,7 +458,7 @@ def index():
return render_template('index_v2.html',
schedule_config=schedule_config,
- main_config=DictWrapper(main_config),
+ main_config=main_config,
main_config_data=main_config_data,
secrets_config=secrets_config_data,
main_config_json=main_config_json,
@@ -472,7 +475,7 @@ def index():
safe_secrets = {'weather': {'api_key': ''}}
return render_template('index_v2.html',
schedule_config={},
- main_config=DictWrapper({}),
+ main_config={},
main_config_data={},
secrets_config=safe_secrets,
main_config_json="{}",