split get_results and analysze

This commit is contained in:
Zeecka
2026-01-02 17:09:22 +01:00
parent e27fbe6511
commit 07d800d583
+18 -11
View File
@@ -104,26 +104,20 @@ class SubprocessAnalyzer(ABC):
raise NotImplementedError("cmd must be set or build_cmd overridden")
return self.cmd
@overload
def analyze(self) -> None: ...
@overload
def analyze(self, password: str) -> None: ...
def analyze(self, password: Optional[str] = None) -> None:
"""Run the subprocess command and handle results."""
def get_results(self, password: Optional[str] = None) -> dict[str, Any]:
"""Get results of command before returning."""
result: dict[str, Any]
try:
extracted_dir = None
if self.has_archive:
extracted_dir = self.get_extracted_dir()
if self.make_folder:
extracted_dir.mkdir(parents=True, exist_ok=True)
cmd: list[str]
if password:
cmd = self.build_cmd(password)
cmd = list(map(str, self.build_cmd(password)))
else:
cmd = self.build_cmd()
cmd = list(map(str, self.build_cmd()))
data = self.run_command(cmd, cwd=self.output_dir)
returncode = data.returncode
stderr = data.stderr
@@ -149,6 +143,19 @@ class SubprocessAnalyzer(ABC):
result["note"] = note
if zip_exist:
result["download"] = f"/download/{self.output_dir.name}/{self.name}"
return result
@overload
def analyze(self) -> None: ...
@overload
def analyze(self, password: str) -> None: ...
def analyze(self, password: Optional[str] = None) -> None:
"""Run the subprocess command and handle results."""
result: dict[str, Any]
try:
result = self.get_results(password)
self.update_result(result)
except Exception as e:
self.update_result({"status": "error", "error": str(e)})