Start the puppet main process.
(self)
| 167 | return viewer_url |
| 168 | |
| 169 | def start_puppet(self): |
| 170 | """Start the puppet main process.""" |
| 171 | # Remove lockfile if exists |
| 172 | if os.path.isfile(self.lockfile): |
| 173 | os.remove(self.lockfile) |
| 174 | |
| 175 | # Get the src directory for proper module imports |
| 176 | src_dir = os.path.dirname(self.main_py) |
| 177 | project_root = os.path.dirname(src_dir) |
| 178 | |
| 179 | # Open a log file to capture output (keep it open) |
| 180 | log_path = os.path.join(project_root, "puppet.log") |
| 181 | self.log_file = open(log_path, "w") |
| 182 | |
| 183 | # Start the main.py process directly (cli.sh logic is handled in GUI) |
| 184 | env = os.environ.copy() |
| 185 | env['PYTHONPATH'] = src_dir |
| 186 | |
| 187 | self.process = subprocess.Popen( |
| 188 | ["python", self.main_py], |
| 189 | stdout=self.log_file, |
| 190 | stderr=subprocess.STDOUT, |
| 191 | env=env, |
| 192 | cwd=src_dir |
| 193 | ) |
| 194 | return self.process |
| 195 | |
| 196 | def stop_puppet(self): |
| 197 | """Stop the puppet process.""" |