Skip to content

Commit bd311a2

Browse files
committed
fix: make README quickstart smoke test daemon-independent
1 parent 5958842 commit bd311a2

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,23 @@ pilotctl daemon start --hostname my-agent
3232
Then, from your code:
3333

3434
```python
35-
from pilotprotocol import Driver
36-
37-
with Driver() as d:
38-
info = d.info()
39-
print(f"address={info['address']}")
40-
41-
d.set_hostname("my-python-agent")
35+
from pilotprotocol import Driver, PilotError
4236

43-
peer = d.resolve_hostname("other-agent")
44-
with d.dial(f"{peer['address']}:1000") as conn:
45-
conn.write(b"hello")
46-
print(conn.read(4096))
37+
try:
38+
with Driver() as d:
39+
info = d.info()
40+
print(f"address={info['address']}")
41+
42+
d.set_hostname("my-python-agent")
43+
44+
peer = d.resolve_hostname("other-agent")
45+
with d.dial(f"{peer['address']}:1000") as conn:
46+
conn.write(b"hello")
47+
print(conn.read(4096))
48+
except (PilotError, FileNotFoundError) as e:
49+
# Raised when libpilot isn't installed or no daemon is running.
50+
# Start one with: pilotctl daemon start --hostname my-agent
51+
print(f"pilot daemon unavailable: {e}")
4752
```
4853

4954
## API overview
@@ -65,7 +70,7 @@ from pilotprotocol import Driver, PilotError
6570
try:
6671
with Driver() as d:
6772
d.resolve_hostname("unknown")
68-
except PilotError as e:
73+
except (PilotError, FileNotFoundError) as e:
6974
print(f"error: {e}")
7075
```
7176

0 commit comments

Comments
 (0)