Skip to content

Commit a5754e6

Browse files
committed
feat(pydriver): add demo scripts for busybox and pip install
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 34f2502 commit a5754e6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import subprocess
2+
3+
cmds = [
4+
(["echo", "hello from hyperlight guest"], None),
5+
(["uname", "-a"], None),
6+
(["ls", "/bin"], None),
7+
(["grep", "nameserver", "/etc/resolv.conf"], None),
8+
(["find", "/etc", "-name", "*.conf"], None),
9+
(["wc", "-l", "/etc/resolv.conf"], None),
10+
(["sh", "-c", "echo hello from sh"], None),
11+
]
12+
13+
for cmd, stdin in cmds:
14+
label = " ".join(cmd)
15+
print(f"\n$ {label}")
16+
r = subprocess.run(cmd, capture_output=True, text=True, input=stdin)
17+
if r.stdout:
18+
print(r.stdout.rstrip())
19+
if r.stderr:
20+
print(f"stderr: {r.stderr.rstrip()}")
21+
if r.returncode != 0:
22+
print(f"exit code: {r.returncode}")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess, sys
2+
3+
result = subprocess.run(
4+
[sys.executable, "-m", "pip", "install", "six"],
5+
capture_output=True, text=True,
6+
)
7+
print(result.stdout)
8+
if result.returncode != 0:
9+
print(result.stderr)
10+
sys.exit(result.returncode)
11+
12+
import six
13+
print(f"Installed and imported six {six.__version__}")

0 commit comments

Comments
 (0)