mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
moving away from dict errors
This commit is contained in:
@@ -877,11 +877,11 @@
|
||||
<div class="stat-label">CPU Temperature</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ main_config.display.hardware.brightness if main_config and main_config.display and main_config.display.hardware and main_config.display.hardware.brightness is defined else 0 }}</div>
|
||||
<div class="stat-value">{{ main_config.get('display', {}).get('hardware', {}).get('brightness', 0) }}</div>
|
||||
<div class="stat-label">Brightness</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ main_config.display.hardware.cols if main_config and main_config.display and main_config.display.hardware and main_config.display.hardware.cols is defined else 0 }}x{{ main_config.display.hardware.rows if main_config and main_config.display and main_config.display.hardware and main_config.display.hardware.rows is defined else 0 }}</div>
|
||||
<div class="stat-value">{{ main_config.get('display', {}).get('hardware', {}).get('cols', 0) }}x{{ main_config.get('display', {}).get('hardware', {}).get('rows', 0) }}</div>
|
||||
<div class="stat-label">Resolution</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
@@ -1128,7 +1128,7 @@
|
||||
<p class="description">How long each screen is shown before switching. Values in seconds.</p>
|
||||
<form id="durations-form">
|
||||
<div class="form-row">
|
||||
{% for key, value in main_config.display.display_durations.items() %}
|
||||
{% for key, value in main_config.get('display', {}).get('display_durations', {}).items() %}
|
||||
<div class="form-group">
|
||||
<label for="duration_{{ key }}">{{ key | replace('_', ' ') | title }}</label>
|
||||
<input type="number" class="form-control duration-input" id="duration_{{ key }}" data-name="{{ key }}" value="{{ value }}" min="5" max="600">
|
||||
|
||||
32
update_pi_files.py
Normal file
32
update_pi_files.py
Normal file
@@ -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)
|
||||
@@ -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="{}",
|
||||
|
||||
Reference in New Issue
Block a user