Add config UI interface and update app.py with config card functionality
- Copied config.py with FreeSimpleGUI configuration interface to root folder - Added load_config() function to launch config UI when card 12886709 is inserted - Config UI allows setting hostname and work table (Loc De Munca) - Automatic printer configuration and hostname updates - System reboot after configuration changes - Added config.py to version control
This commit is contained in:
@@ -652,6 +652,11 @@ def read_name_from_file():
|
||||
|
||||
# Function to send logs to a remote server for the Server_monitorizare APP
|
||||
def send_log_to_server(log_message, n_masa, hostname, device_ip):
|
||||
# Skip sending logs if device is not configured
|
||||
if n_masa == "noconfig":
|
||||
logging.debug(f"Skipping server log (device not configured): {log_message}")
|
||||
return
|
||||
|
||||
host = hostname
|
||||
device = device_ip
|
||||
try:
|
||||
@@ -1125,12 +1130,60 @@ def check_internet_connection():
|
||||
log_info_with_server(f"An error occurred during internet check: {e}")
|
||||
time.sleep(60) # Retry after 1 minute in case of an error
|
||||
|
||||
# Function to launch Chromium
|
||||
def launch_chromium():
|
||||
"""
|
||||
Launch Chromium with either production URL or local fallback page
|
||||
"""
|
||||
try:
|
||||
# Determine which URL to use based on device configuration
|
||||
if name != "noconfig":
|
||||
# Device is configured - use production URL
|
||||
url = "http://10.76.140.17/iweb_v2/index.php/traceability/production"
|
||||
print(f"Device configured as '{name}'. Launching production URL: {url}")
|
||||
log_info_with_server(f"Launching Chromium with production URL for device: {name}")
|
||||
else:
|
||||
# Device not configured - use local HTML file
|
||||
local_html_dir = "./data/html"
|
||||
local_html_file = os.path.join(local_html_dir, "Screen.html")
|
||||
|
||||
# Create directory if it doesn't exist
|
||||
os.makedirs(local_html_dir, exist_ok=True)
|
||||
|
||||
# Check if local HTML file exists
|
||||
if not os.path.exists(local_html_file):
|
||||
print(f"Warning: Local HTML file not found at {local_html_file}")
|
||||
print(f"Please create the file or copy it from the data/html directory")
|
||||
logging.warning(f"Local HTML file not found: {local_html_file}")
|
||||
|
||||
# Convert to file:// URL for local file
|
||||
url = f"file://{os.path.abspath(local_html_file)}"
|
||||
print(f"Device not configured. Launching local fallback page: {url}")
|
||||
log_info_with_server("Device not configured. Launching local fallback page")
|
||||
|
||||
# Launch Chromium with the determined URL - using same parameters as v3
|
||||
print("Starting Chromium...")
|
||||
subprocess.Popen(
|
||||
["chromium", "--test-type", "--noerrors", "--kiosk", "--start-fullscreen",
|
||||
"--unsafely-treat-insecure-origin-as-secure=http://10.76.140.17", url],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
|
||||
start_new_session=True
|
||||
)
|
||||
print("✓ Chromium launched successfully")
|
||||
log_info_with_server("Chromium launched successfully")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Failed to launch Chromium: {e}")
|
||||
log_info_with_server(f"Failed to launch Chromium: {e}")
|
||||
|
||||
# Start the internet connection check in a separate process
|
||||
internet_check_process = Process(target=check_internet_connection)
|
||||
internet_check_process.start()
|
||||
url = "10.76.140.17/iweb_v2/index.php/traceability/production" # pentru cazul in care raspberiul nu are sistem de prezenta
|
||||
# Launch Chromium with the specified URLs
|
||||
subprocess.Popen(["chromium", "--test-type", "--noerrors", "--kiosk", "--start-fullscreen", "--unsafely-treat-insecure-origin-as-secure=http://10.76.140.17", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL, start_new_session=True)
|
||||
|
||||
# Launch Chromium in any situation
|
||||
print("Initializing Chromium launcher...")
|
||||
time.sleep(2) # Give system time to stabilize
|
||||
launch_chromium()
|
||||
|
||||
info = "0"
|
||||
#function to post info
|
||||
|
||||
Reference in New Issue
Block a user