@@ -551,13 +551,13 @@ def telemetry():
551551def run_bridge_server ():
552552 """The entry point for the background process."""
553553 if not HAS_WEB_DEPS :
554- print (_ ('❌ Flask missing. Cannot start server.' ))
554+ safe_print (_ ('❌ Flask missing. Cannot start server.' ))
555555 sys .exit (1 )
556556
557557 try :
558558 port = find_free_port (5000 )
559559 except RuntimeError as e :
560- print (_ ('❌ {}' ).format (e ))
560+ safe_print (_ ('❌ {}' ).format (e ))
561561 sys .exit (1 )
562562
563563 print (_ ('Local Port: {}' ).format (port ), flush = True )
@@ -580,16 +580,16 @@ def __init__(self):
580580 def start (self ):
581581 """Start the web bridge in background."""
582582 if not HAS_WEB_DEPS :
583- print (_ ('❌ Dependencies missing. Please run: pip install flask flask-cors' ))
583+ safe_print (_ ('❌ Dependencies missing. Please run: pip install flask flask-cors' ))
584584 return 1
585585
586586 if self .is_running ():
587587 port = self ._get_port ()
588- print (_ ('✅ Web bridge already running on port {}' ).format (port ))
589- print (_ ('🌍 Dashboard: {}#{}' ).format (PRIMARY_DASHBOARD , port ))
588+ safe_print (_ ('✅ Web bridge already running on port {}' ).format (port ))
589+ safe_print (_ ('🌍 Dashboard: {}#{}' ).format (PRIMARY_DASHBOARD , port ))
590590 return 0
591591
592- print (_ ('🚀 Starting web bridge...' ))
592+ safe_print (_ ('🚀 Starting web bridge...' ))
593593 cmd = [sys .executable , "-m" , "omnipkg.apis.local_bridge" ]
594594
595595 # Cross-platform detachment logic
@@ -616,29 +616,29 @@ def start(self):
616616 port = self ._get_port ()
617617 url = f"{ PRIMARY_DASHBOARD } #{ port } "
618618 print ("=" * 60 )
619- print (_ ('✅ Web bridge started successfully' ))
620- print (_ ('🔗 Local Port: {}' ).format (port ))
621- print (_ ('📊 PID: {}' ).format (process .pid ))
622- print (_ ('🌍 Dashboard: {}' ).format (url ))
619+ safe_print (_ ('✅ Web bridge started successfully' ))
620+ safe_print (_ ('🔗 Local Port: {}' ).format (port ))
621+ safe_print (_ ('📊 PID: {}' ).format (process .pid ))
622+ safe_print (_ ('🌍 Dashboard: {}' ).format (url ))
623623 print ("=" * 60 )
624624 webbrowser .open (url )
625625 return 0
626626 else :
627- print (_ ('❌ Failed to start. Check logs.' ))
627+ safe_print (_ ('❌ Failed to start. Check logs.' ))
628628 return 1
629629 except Exception as e :
630- print (_ ('❌ Launch error: {}' ).format (e ))
630+ safe_print (_ ('❌ Launch error: {}' ).format (e ))
631631 return 1
632632
633633 def stop (self ):
634634 """Stop the web bridge safely across platforms."""
635635 if not self .is_running ():
636- print (_ ('⚠️ Web bridge is not running' ))
636+ safe_print (_ ('⚠️ Web bridge is not running' ))
637637 return 0
638638
639639 try :
640640 pid = int (self .pid_file .read_text ())
641- print (_ ('🛑 Stopping web bridge (PID: {})...' ).format (pid ))
641+ safe_print (_ ('🛑 Stopping web bridge (PID: {})...' ).format (pid ))
642642
643643 if os .name == 'nt' :
644644 subprocess .run (["taskkill" , "/PID" , str (pid ), "/T" , "/F" ],
@@ -651,33 +651,33 @@ def stop(self):
651651
652652 if self .pid_file .exists ():
653653 self .pid_file .unlink ()
654- print (_ ('✅ Web bridge stopped' ))
654+ safe_print (_ ('✅ Web bridge stopped' ))
655655 return 0
656656 except Exception as e :
657- print (_ ('❌ Error stopping: {}' ).format (e ))
657+ safe_print (_ ('❌ Error stopping: {}' ).format (e ))
658658 if self .pid_file .exists ():
659659 self .pid_file .unlink ()
660660 return 1
661661
662662 def restart (self ):
663663 """Restart the web bridge."""
664- print (_ ('🔄 Restarting web bridge...' ))
664+ safe_print (_ ('🔄 Restarting web bridge...' ))
665665 self .stop ()
666666 time .sleep (1 )
667667 return self .start ()
668668
669669 def status (self ):
670670 """Check web bridge status."""
671671 if not self .is_running ():
672- print (_ ('❌ Web bridge is not running' ))
673- print (_ ('\n 💡 Start with: 8pkg web start' ))
672+ safe_print (_ ('❌ Web bridge is not running' ))
673+ safe_print (_ ('\n 💡 Start with: 8pkg web start' ))
674674 return 1
675675
676676 if not HAS_SYS_DEPS :
677- print (_ ("⚠️ 'psutil' not installed. Limited status info available." ))
677+ safe_print (_ ("⚠️ 'psutil' not installed. Limited status info available." ))
678678 pid = int (self .pid_file .read_text ())
679679 port = self ._get_port ()
680- print (_ ('✅ Running (PID: {}, Port: {})' ).format (pid , port ))
680+ safe_print (_ ('✅ Running (PID: {}, Port: {})' ).format (pid , port ))
681681 return 0
682682
683683 pid = int (self .pid_file .read_text ())
@@ -689,28 +689,28 @@ def status(self):
689689 uptime = time .time () - process .create_time ()
690690
691691 print ("=" * 60 )
692- print (_ ('✅ Web Bridge Status: RUNNING' ))
692+ safe_print (_ ('✅ Web Bridge Status: RUNNING' ))
693693 print ("=" * 60 )
694- print (_ ('🔗 Port: {}' ).format (port ))
695- print (_ ('📊 PID: {}' ).format (pid ))
696- print (f"💾 Memory: { mem_info .rss / 1024 / 1024 :.1f} MB" )
697- print (_ ('⏱️ Uptime: {}' ).format (self ._format_uptime (uptime )))
698- print (_ ('🌍 Dashboard: {}#{}' ).format (PRIMARY_DASHBOARD , port ))
694+ safe_print (_ ('🔗 Port: {}' ).format (port ))
695+ safe_print (_ ('📊 PID: {}' ).format (pid ))
696+ safe_print (f"💾 Memory: { mem_info .rss / 1024 / 1024 :.1f} MB" )
697+ safe_print (_ ('⏱️ Uptime: {}' ).format (self ._format_uptime (uptime )))
698+ safe_print (_ ('🌍 Dashboard: {}#{}' ).format (PRIMARY_DASHBOARD , port ))
699699 print ("=" * 60 )
700700 return 0
701701 except psutil .NoSuchProcess :
702- print (_ ('⚠️ PID file exists but process is dead. Cleaning up...' ))
702+ safe_print (_ ('⚠️ PID file exists but process is dead. Cleaning up...' ))
703703 self .pid_file .unlink ()
704704 return 1
705705
706706 def show_logs (self , follow = False , lines = 50 ):
707707 """Display web bridge logs."""
708708 if not self .log_file .exists ():
709- print (_ ('❌ Log file not found: {}' ).format (self .log_file ))
709+ safe_print (_ ('❌ Log file not found: {}' ).format (self .log_file ))
710710 return 1
711711
712712 if follow :
713- print (_ ('📝 Following logs (Ctrl+C to stop)...\n ' ))
713+ safe_print (_ ('📝 Following logs (Ctrl+C to stop)...\n ' ))
714714 try :
715715 subprocess .run (["tail" , "-f" , str (self .log_file )], check = True )
716716 except (FileNotFoundError , subprocess .CalledProcessError ):
@@ -727,7 +727,7 @@ def show_logs(self, follow=False, lines=50):
727727 pass
728728 except KeyboardInterrupt :
729729 pass
730- print (_ ('\n ✅ Stopped following logs' ))
730+ safe_print (_ ('\n ✅ Stopped following logs' ))
731731 return 0
732732 else :
733733 try :
0 commit comments