Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
fix cli test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKraus authored and ml-evs committed Nov 9, 2023
1 parent 1ec9b59 commit afc47d4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions marda_extractors_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
import urllib.request
import venv
import platform
from enum import Enum
from pathlib import Path
from types import ModuleType
Expand All @@ -14,6 +15,7 @@
__all__ = ("extract", "MardaExtractor")

REGISTRY_BASE_URL = "https://marda-registry.fly.dev"
BIN = "Scripts" if platform.system() == "Windows" else "bin"


class SupportedExecutionMethod(Enum):
Expand Down Expand Up @@ -156,7 +158,7 @@ def install(self):
try:
for p in instructions["packages"]:
command = [
str(self.venv_dir / "bin" / "python")
str(self.venv_dir / BIN / "python")
if self.venv_dir
else "python",
"-m",
Expand Down Expand Up @@ -234,14 +236,14 @@ def execute(
return output

def _execute_cli(self, command):
print(f"Exexcuting {command=}")
print(f"Executing {command=}")
results = subprocess.check_output(command, shell=True)
return results

def _execute_cli_venv(self, command):
print(f"Exexcuting {command=} in venv")
py_cmd = "import subprocess; return subprocess.check_output(f'{command}', shell=True)"
command = [str(self.venv_dir / "bin" / "python"), "-c", py_cmd]
print(f"Executing {command=} in venv")
py_cmd = f"import subprocess; subprocess.check_output(r'{command}', shell=True)"
command = [str(self.venv_dir / BIN / "python"), "-c", py_cmd]
results = subprocess.check_output(command)
return results

Expand Down Expand Up @@ -299,7 +301,7 @@ def _execute_python_venv(self, entry_command: str, setup: str):
if not self.venv_dir:
raise RuntimeError("Something has gone wrong; no `venv_dir` set")

command = [str(self.venv_dir / "bin" / "python"), "-c", py_cmd]
command = [str(self.venv_dir / BIN / "python"), "-c", py_cmd]
subprocess.check_output(
command,
)
Expand Down

0 comments on commit afc47d4

Please sign in to comment.