(self)
| 13150 | return None, str(script_dir) |
| 13151 | |
| 13152 | def _install_ghunt_runtime(self): |
| 13153 | if os.environ.get("INTELOSINT_AUTO_INSTALL_GHUNT", "1").strip().lower() != "1": |
| 13154 | return {"ok": False, "message": "Ghunt non disponibile. Imposta INTELOSINT_AUTO_INSTALL_GHUNT=1 o installalo manualmente."} |
| 13155 | run_env = os.environ.copy() |
| 13156 | run_env["PYTHONIOENCODING"] = "utf-8" |
| 13157 | run_dir = Path(__file__).resolve().parent |
| 13158 | py = str(sys.executable) |
| 13159 | if os.name == "nt": |
| 13160 | terminal_command = ( |
| 13161 | 'echo [1/2] Aggiornamento pip corrente... ' |
| 13162 | f'&& "{py}" -m pip install --upgrade pip ' |
| 13163 | '&& echo [2/2] Installazione pacchetto ghunt... ' |
| 13164 | f'&& "{py}" -m pip install ghunt ' |
| 13165 | '&& echo Installazione terminata. Controlla eventuali warning sopra. ' |
| 13166 | '&& echo Premi un tasto per chiudere questa finestra... ' |
| 13167 | '&& pause' |
| 13168 | ) |
| 13169 | terminal_cmd = f'start "" /D "{run_dir}" cmd /k "{terminal_command}"' |
| 13170 | try: |
| 13171 | subprocess.Popen( |
| 13172 | terminal_cmd, |
| 13173 | cwd=str(run_dir), |
| 13174 | env=run_env, |
| 13175 | shell=True, |
| 13176 | ) |
| 13177 | return {"ok": True, "message": "Installazione avviata in finestra terminale.", "launch": {"mode": "windows-cmd"}} |
| 13178 | except Exception as e: |
| 13179 | return {"ok": False, "message": f"Impossibile aprire terminale per installare GHunt: {e}"} |
| 13180 | |
| 13181 | terminals = [ |
| 13182 | ("gnome-terminal", "--", "bash", "-lc"), |
| 13183 | ("konsole", "-e", "bash", "-lc"), |
| 13184 | ("xterm", "-hold", "-e", "bash", "-lc"), |
| 13185 | ("tilix", "-e", "bash", "-lc"), |
| 13186 | ("alacritty", "-e", "bash", "-lc"), |
| 13187 | ] |
| 13188 | shell_payload = ( |
| 13189 | f'cd "{run_dir}" && ' |
| 13190 | 'echo "[1/2] Aggiornamento pip corrente..." && ' |
| 13191 | f'"{py}" -m pip install --upgrade pip && ' |
| 13192 | 'echo "[2/2] Installazione pacchetto ghunt..." && ' |
| 13193 | f'"{py}" -m pip install ghunt && ' |
| 13194 | 'echo "Installazione terminata. Lascia aperto il terminale per eventuali controlli." && ' |
| 13195 | 'exec bash' |
| 13196 | ) |
| 13197 | for terminal in terminals: |
| 13198 | exe = shutil.which(terminal[0]) |
| 13199 | if exe: |
| 13200 | terminal_cmd = [terminal[0], *terminal[1:], shell_payload] |
| 13201 | try: |
| 13202 | subprocess.Popen(terminal_cmd, cwd=str(run_dir), env=run_env) |
| 13203 | return {"ok": True, "message": "Installazione avviata in finestra terminale.", "launch": {"mode": "linux-terminal"}} |
| 13204 | except Exception: |
| 13205 | continue |
| 13206 | |
| 13207 | try: |
| 13208 | # Fallback silenzioso: installazione in background (solo se nessun terminale disponibile) |
| 13209 | subprocess.Popen( |
no outgoing calls
no test coverage detected