MCPcopy
hub / github.com/potpie-ai/potpie / exec

Method exec

potpie/sandbox/tests/unit/test_daytona_provider.py:60–85  ·  view source on GitHub ↗
(self, command: str, **kwargs: object)

Source from the content-addressed store, hash-verified

58 self.fake_paths: set[str] = set()
59
60 def exec(self, command: str, **kwargs: object) -> FakeResponse:
61 self.commands.append({"command": command, **kwargs})
62 if command == "pwd":
63 return FakeResponse(result=str(kwargs.get("cwd", "")))
64 if command.startswith(("test -d ", "test -e ", "test -f ")):
65 target = command.split(" ", 2)[2].strip("'\"")
66 return FakeResponse(
67 exit_code=0 if target in self.fake_paths else 1,
68 result="",
69 )
70 if command.startswith("git clone "):
71 parts = command.split()
72 path = parts[-1].strip("'\"")
73 if "--bare" in parts:
74 self.fake_paths.add(f"{path}/HEAD")
75 else:
76 self.fake_paths.add(f"{path}/.git")
77 elif "worktree add" in command:
78 parts = command.split()
79 try:
80 tree_idx = parts.index("--") + 1
81 tree_path = parts[tree_idx].strip("'\"")
82 self.fake_paths.add(f"{tree_path}/.git")
83 except (ValueError, IndexError):
84 pass
85 return FakeResponse(result="ok")
86
87 def mark_bare(self, path: str) -> None:
88 """Test helper: pretend a bare clone exists at `path`."""

Calls 4

FakeResponseClass · 0.85
appendMethod · 0.45
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected