@@ -68,6 +68,9 @@ def __init__(self, config_path='config.yaml'):
6868 self .active_processes = []
6969
7070 self .ram_threshold = self .config .get ('ram_threshold' , 80 )
71+
72+
73+ self .is_windows = os .name == 'nt'
7174
7275 def load_config (self , path ):
7376 """
@@ -86,6 +89,7 @@ def load_config(self, path):
8689 def start_scripts (self ):
8790 """Starts all projects defined in the configuration."""
8891 self .active_processes = [] # Clear the list before starting
92+
8993 for project in self .projects :
9094 project_name = project .get ('name' )
9195 script_path = project .get ('path' )
@@ -94,7 +98,7 @@ def start_scripts(self):
9498 # Check if the script is Python
9599 if script_path .endswith ('.py' ):
96100 try :
97- if os . name == 'nt' :
101+ if self . is_windows :
98102 venv_python = os .path .join (
99103 project_dir , '.venv' , 'Scripts' , 'python.exe'
100104 )
@@ -149,13 +153,27 @@ def start_scripts(self):
149153 )
150154
151155 # Invalid extension handling
156+ elif script_path .endswith ('.exe' ) and self .is_windows :
157+ try :
158+ command = ['cmd.exe' , '/c' , str (script_path )]
159+
160+ proc = subprocess .Popen (
161+ command ,
162+ cwd = str (project_dir ),
163+ creationflags = subprocess .CREATE_NEW_CONSOLE ,
164+ )
165+ self .active_processes .append (proc )
166+
167+ except Exception as e :
168+ print (
169+ f'[bold red]Error executing { project_name } :[/bold red]'
170+ f'{ e } '
171+ )
152172 else :
153173 print (
154- f'[yellow]Warning:[/yellow] The project { project_name } '
155- 'was skipped (invalid extension).'
156- '\n Try again with a script:[red] [.py, .js, .ts or .exe]'
174+ f"\n [yellow]Warning:[/yellow] The project [bold]{ project_name } [/bold] was skipped (invalid extension).\n "
175+ f"Try again with a script: [red][.py, .exe][/red] or a Node.js project with a [red]package.json[/red] in the folder."
157176 )
158-
159177 def stop_scripts (self ):
160178 """Terminates active scripts and their child processes."""
161179 print (
@@ -190,6 +208,7 @@ def process_manager(self):
190208 current_ram = self .ram_monitoring .get_percent ()
191209 is_ram_critical = current_ram > self .ram_threshold
192210
211+
193212 if (is_heavy_process_open or is_ram_critical ) and script_running :
194213 if is_heavy_process_open :
195214 detected = [k for k , v in status_dict .items () if v ]
@@ -212,8 +231,8 @@ def process_manager(self):
212231 and not script_running
213232 ):
214233 print (
215- f""" [bold green]System stable (RAM: { current_ram } %).
216- Restarting scripts...[/bold green]"""
234+ f' \n [bold green]System stable (RAM: { current_ram } %).'
235+ 'Starting scripts...[/bold green]'
217236 )
218237 self .start_scripts ()
219238 script_running = True
@@ -222,9 +241,12 @@ def process_manager(self):
222241 # or just pass
223242 pass
224243
244+ print ()
245+ if not self .active_processes :
246+ print ("[bold red]No valid scripts found to start. FortScript is shutting down.[/bold red]" )
247+ break
225248 time .sleep (5 )
226249
227250 def run (self ):
228251 """Runs the main application loop."""
229- print ('Running...' )
230252 self .process_manager ()
0 commit comments