Przeglądaj źródła

fix printer bug

Erwin Jacimino 4 miesięcy temu
rodzic
commit
a59b2cafc5

Plik diff jest za duży
+ 0 - 0
public/main/assets/index-GLEYu3zj.css


Plik diff jest za duży
+ 0 - 0
public/main/assets/index-gL2Wm8Pl.js


Plik diff jest za duży
+ 0 - 0
public/main/assets/index-yQM4v3U3.css


+ 3 - 3
public/main/index.html

@@ -6,7 +6,7 @@
     <title>Pedidos Express</title>
     <link rel="preconnect" href="https://fonts.googleapis.com" />
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
-    <script>
+        <script>
       const params = new URLSearchParams(window.location.search);
       const debug = params.get("debug") === "1";
       if (!debug) {
@@ -17,8 +17,8 @@
       href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Noto+Sans:wght@300;400;500;600;700&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"
       rel="stylesheet"
     />
-  <script type="module" crossorigin src="/express/assets/index-CRM2SbbX.js"></script>
-  <link rel="stylesheet" crossorigin href="/express/assets/index-yQM4v3U3.css">
+  <script type="module" crossorigin src="/express/assets/index-gL2Wm8Pl.js"></script>
+  <link rel="stylesheet" crossorigin href="/express/assets/index-GLEYu3zj.css">
 </head>
   <body>
     <div id="root"></div>

+ 26 - 27
routes/orders.py

@@ -128,9 +128,9 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
             # '-c 1' para Linux/Mac, '-W 2' timeout de 2 segundos para evitar bloqueos largos
             # stdout=subprocess.DEVNULL silencia la salida en consola
             response = subprocess.run(
-                ["ping", "-c", "1", "-W", "2", ip],
+                ["/usr/bin/ping", "-c", "1", "-W", "2", ip],
                 stdout=subprocess.DEVNULL,
-                stderr=subprocess.DEVNULL
+                stderr=subprocess.DEVNULL,
             )
             
             if response.returncode != 0:
@@ -141,33 +141,32 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
             failed_printers.append(name)
     print(failed_printers)
     # Procesamiento de errores
-    if not DEVELOPMENT:
-        if failed_printers:
-            logger.error(f"Printer is not connected: {failed_printers}. Order from user {current_user.email} cannot be processed.")
+    if failed_printers:
+        logger.error(f"Printer is not connected: {failed_printers}. Order from user {current_user.email} cannot be processed.")
+        
+        try:
+            locations_str = ", ".join(failed_printers)
             
-            try:
-                locations_str = ", ".join(failed_printers)
-                
-                email_thread = Thread(
-                    target=get_email_sender().send_email,
-                    args=(
-                        PRINTER_DISCONNECTED_MAIL["subject"].format(location=locations_str),
-                        PRINTER_DISCONNECTED_MAIL["body"].format(
-                            location=locations_str, 
-                            timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
-                        ),
-                        ["erwinjacimino2003@gmail.com", "mompyn@gmail.com"]
+            email_thread = Thread(
+                target=get_email_sender().send_email,
+                args=(
+                    PRINTER_DISCONNECTED_MAIL["subject"].format(location=locations_str),
+                    PRINTER_DISCONNECTED_MAIL["body"].format(
+                        location=locations_str, 
+                        timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                     ),
-                    daemon=True
-                )
-                email_thread.start()
-                
-                return error_response(message=ErrorResponse.PRINTER_DISCONNECTED, status_code=424)
-                
-            except Exception as e:
-                logger.error(f"Error sending notification: {e}")
-                # Retornamos el error original de impresora, no el del email
-                return error_response(message=ErrorResponse.PRINTER_DISCONNECTED, status_code=424)
+                    ["erwinjacimino2003@gmail.com", "mompyn@gmail.com"]
+                ),
+                daemon=True
+            )
+            email_thread.start()
+            
+            return error_response(message=ErrorResponse.PRINTER_DISCONNECTED, status_code=424)
+            
+        except Exception as e:
+            logger.error(f"Error sending notification: {e}")
+            # Retornamos el error original de impresora, no el del email
+            return error_response(message=ErrorResponse.PRINTER_DISCONNECTED, status_code=424)
 
 
     # Input validation

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików