pebble-shimmer 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ __pycache__
2
+ /sandbox
3
+ .idea
4
+ *~
5
+ .venv
6
+ venv
7
+ .vscode
8
+ .coverage
9
+ coverage.xml
10
+ htmlcov
11
+ /.tox
12
+ .*.swp
13
+ .ruff_cache
14
+
15
+ # Tokens and settings for `act` to run GHA locally
16
+ .env
17
+ .envrc
18
+ .secrets
19
+
20
+ # Build artifacts
21
+ /pebble-shimmer.egg-info
22
+ /dist
23
+ /build
24
+ /docs/_build
25
+
26
+ # Agents
27
+ .claude/*local*
28
+
29
+ /.workshop.lock
@@ -0,0 +1,126 @@
1
+ # 2026-06-05
2
+
3
+ Shimmer 1.0.0. The `PebbleCliClient` API is now stable: it matches
4
+ `ops.pebble.Client` method-for-method, return-type-for-return-type, and
5
+ exception-for-exception, as exercised by `tests/integration/test_parity.py`.
6
+
7
+ Features:
8
+
9
+ - The `Development Status` classifier is now `5 - Production/Stable`.
10
+
11
+ Bug fixes and packaging:
12
+
13
+ - The source distribution now includes `CHANGELOG.md`.
14
+
15
+ # 2026-05-31
16
+
17
+ Features:
18
+
19
+ - `push` and `pull` now work correctly with remote `Runner` implementations
20
+ (e.g. `JujuSshRunner`). Runners that implement the new `FileTransferRunner`
21
+ protocol — three methods: `upload_temp`, `download_temp`, and `cleanup_temp`
22
+ — delegate temporary-file staging to the runner rather than assuming a shared
23
+ filesystem. `LocalSubprocessRunner` implements `FileTransferRunner`, so
24
+ existing local-subprocess usage is unchanged. `FileTransferRunner` is
25
+ exported from the top-level `shimmer` package.
26
+
27
+ Bug fixes and packaging:
28
+
29
+ - Python 3.14 is now officially supported and tested.
30
+
31
+ # 2026-05-28
32
+
33
+ Features:
34
+
35
+ - `PebbleCliClient` now accepts an optional `runner=` keyword argument on
36
+ construction. The `Runner` protocol (two methods: `run` and `popen`,
37
+ mirroring `subprocess.run` / `subprocess.Popen`) lets callers swap out how
38
+ the `pebble` binary is invoked — for example, by prefixing the argv with
39
+ `juju ssh --container=<c> <unit> --` to drive a remote Pebble. The default
40
+ behaviour is unchanged: when `runner` is omitted, `LocalSubprocessRunner`
41
+ is used, which reproduces the previous local-subprocess behaviour
42
+ byte-for-byte. Both `Runner` and `LocalSubprocessRunner` are exported from
43
+ the top-level `shimmer` package.
44
+
45
+ `get_notices()` and `get_notice()` now use Pebble's structured `--format json`
46
+ output instead of scraping the human-readable table and parsing per-notice
47
+ YAML. `get_notices()` reads every matching notice in a single call (it no
48
+ longer makes a follow-up call per notice).
49
+
50
+ Bug fixes and packaging:
51
+
52
+ - `get_notices(types=...)` now filters correctly. It previously passed the
53
+ type as a positional argument, which newer Pebble rejects with "too many
54
+ arguments"; types are now passed via the `--type` flag.
55
+
56
+ # 2026-05-22
57
+
58
+ Features:
59
+
60
+ Use Pebble's structured `--format json` output for read commands
61
+ (`get_services`, `get_checks`, `list_files`, `get_changes`, `get_change`,
62
+ `get_identities`). This is more robust than scraping human-readable tables and
63
+ restores information the text parser had to drop or guess: change `kind`,
64
+ `tasks` and `err`; check `successes`/`failures`/`threshold`/`change_id`; real
65
+ file `user_id`/`group_id`/`size`/`type`; and identity local `user_id`.
66
+
67
+ Requires a Pebble build that supports `--format` on read commands.
68
+
69
+ Bug fixes and packaging:
70
+
71
+ - `get_warnings()` now correctly returns an empty list when there are no
72
+ warnings (it previously always raised `NotImplementedError`).
73
+ - `notify()` raises `ValueError` (instead of `assert`-ing) for non-custom
74
+ notice types, and renders `repeat_after` as a valid Pebble duration string.
75
+ - `socket_path` now also sets the `PEBBLE_SOCKET` environment variable, as
76
+ documented.
77
+ - The pebble exception types (`Error`, `APIError`, `ChangeError`,
78
+ `ConnectionError`, `ExecError`, `PathError`, `ProtocolError`, `TimeoutError`)
79
+ can now be imported directly from `shimmer` (e.g. `from shimmer import
80
+ APIError`); previously they had to be imported from `ops.pebble`.
81
+ - `get_notice()` and `get_notices()` now return correctly-typed `Notice`
82
+ objects (real `last_occurred`/`last_data`/`expire_after`) parsed from
83
+ Pebble's per-ID YAML. `get_notice(id)` previously returned the wrong notice
84
+ or raised `IndexError`.
85
+ - `send_signal()` accepts bare signal names (e.g. `"HUP"`) in addition to the
86
+ `"SIGHUP"` form, matching `ops.pebble.Client`; invalid names raise
87
+ `ValueError`.
88
+ - `ExecProcess.wait()` no longer deadlocks when a process emits more than the
89
+ OS pipe buffer (~64KB) before exiting, and now feeds `stdin`. It is
90
+ reimplemented in terms of `communicate()`.
91
+ - Ship a `py.typed` marker so downstream type checkers use Shimmer's types.
92
+ - `__version__` is derived from the installed package metadata.
93
+ - `APIError` raised on a CLI failure now mirrors `ops.pebble.Client`: `code`
94
+ is the inferred HTTP status (e.g. `404` for not-found, `400` for bad
95
+ requests) instead of the process exit code, `status` is the matching reason
96
+ phrase, `message` drops the CLI's `error:` prefix so it matches the daemon's
97
+ message verbatim, and `body` uses Pebble's wire format
98
+ (`{"type": "error", "status-code": ..., "result": {"message": ...}}`).
99
+ Errors that can't be classified fall back to `500`. Code that branches on
100
+ `APIError.code` (e.g. `== 404`) now works portably across both clients.
101
+ - `abort_change()` now exists on `PebbleCliClient`, so the client implements
102
+ the full `ops.pebble.Client` surface (and its own `PebbleClientProtocol`).
103
+ The Pebble CLI exposes no command to abort a change, so it raises a clear
104
+ `NotImplementedError` explaining the limitation instead of failing with
105
+ `AttributeError`.
106
+ - `pull()` now returns a file handle that streams from disk instead of
107
+ buffering the whole file into an in-memory `io.StringIO`/`io.BytesIO`. This
108
+ matches `ops.pebble.Client.pull` (which also returns an open file object over
109
+ an unlinked temp file), so large files no longer require a full extra copy in
110
+ memory. The return value is still a readable text/binary file object.
111
+
112
+ # 2025-07-25
113
+
114
+ Add missing overloads on pull() and exec().
115
+
116
+ # 2025-07-21
117
+
118
+ Add get_change().
119
+
120
+ # 2025-07-20
121
+
122
+ Allow Python 3.11.
123
+
124
+ # 2025-07-12
125
+
126
+ Initial alpha version.
@@ -0,0 +1,203 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: pebble-shimmer
3
+ Version: 1.0.0
4
+ Summary: A drop-in replacement for ops.pebble.Client that uses the Pebble CLI
5
+ Project-URL: Homepage, https://github.com/tonyandrewmeyer/shimmer
6
+ Project-URL: Repository, https://github.com/tonyandrewmeyer/shimmer
7
+ Project-URL: Documentation, https://github.com/tonyandrewmeyer/shimmer#readme
8
+ Project-URL: Bug Tracker, https://github.com/tonyandrewmeyer/shimmer/issues
9
+ Author-email: Tony Meyer <shimmer@aotearoa.dev>
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Systems Administration
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: ops<4,>=2.0.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Shimmer — a shiny Pebble client
28
+
29
+ A 100% compatible, drop-in replacement for `ops.pebble.Client` that drives
30
+ [Pebble](https://documentation.ubuntu.com/pebble) through its **CLI** instead of
31
+ the unix socket — for environments where the socket isn't reachable (such as a
32
+ Rock or a Juju container).
33
+
34
+ ![Shimmer parity demo](https://raw.githubusercontent.com/tonyandrewmeyer/shimmer/main/demo.gif)
35
+
36
+ <sub>The same deploy-and-verify routine run over `ops.pebble.Client` (unix
37
+ socket, left) and `shimmer.PebbleCliClient` (CLI, right) — identical results.</sub>
38
+
39
+ ## Overview
40
+
41
+ `PebbleCliClient` implements the same interface as `ops.pebble.Client`: same
42
+ method signatures, same return types, same raised exceptions. Under the hood it
43
+ translates each call into a `pebble` CLI command, parses the output back into the
44
+ same Python objects `ops` returns, and maps CLI errors onto the matching
45
+ exceptions. The contract is **parity** — code written against `ops.pebble.Client`
46
+ should run unchanged against Shimmer.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # From PyPI
52
+ uv pip install pebble-shimmer
53
+
54
+ # Development version
55
+ git clone https://github.com/tonyandrewmeyer/shimmer
56
+ cd shimmer
57
+ uv pip install -e .
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ Construct the client, then use it exactly like `ops.pebble.Client` — the methods,
63
+ arguments, return types, and exceptions are the same:
64
+
65
+ ```python
66
+ from shimmer import PebbleCliClient as Client
67
+
68
+ client = Client()
69
+ client.replan_services()
70
+ for service in client.get_services():
71
+ print(service.name, service.current.value)
72
+ ```
73
+
74
+ The whole point is that there's nothing new to learn: the full method surface is
75
+ documented by [`ops.pebble.Client`](https://ops.readthedocs.io/en/latest/reference/pebble.html).
76
+ Swapping `ops.pebble.Client` for `shimmer.PebbleCliClient` is the only change.
77
+
78
+ The constructor is where Shimmer differs, since it talks to a binary rather than
79
+ a socket:
80
+
81
+ ```python
82
+ client = Client(
83
+ socket_path="/var/lib/pebble/default/.pebble.socket", # sets PEBBLE / PEBBLE_SOCKET
84
+ pebble_binary="/snap/bin/pebble", # path to the pebble binary (default: "pebble")
85
+ timeout=5.0, # default per-command timeout in seconds
86
+ )
87
+ ```
88
+
89
+ `socket_path` doesn't open a socket — it points Shimmer at the daemon by setting
90
+ `PEBBLE` (its parent directory) and `PEBBLE_SOCKET` for the CLI. For drop-in
91
+ parity the constructor also accepts `opener` and `base_url`, but those only
92
+ configure the socket transport, so Shimmer accepts and ignores them. The
93
+ `ops.pebble` exceptions are re-exported from `shimmer` for convenience, but they
94
+ are the same objects, so `except ops.pebble.APIError` keeps working too.
95
+
96
+ ## Demo and verification
97
+
98
+ The GIF above is a recording of [`demo.md`](demo.md) — a
99
+ [Showboat](https://pypi.org/project/showboat/) document that runs one
100
+ deploy-and-verify routine against the **real socket client**, then the **same
101
+ code** against Shimmer, and `diff`s the two outputs to prove they're identical.
102
+ It's reproducible:
103
+
104
+ ```bash
105
+ uv run python demo.py # rebuild demo.md (verifies parity live)
106
+ uv run python demo.py --record # re-record demo.cast (needs tmux + asciinema)
107
+ agg demo.cast demo.gif # regenerate the GIF from the cast
108
+ ```
109
+
110
+ Parity is also exercised in CI by `tests/integration/test_parity.py`, which runs
111
+ the same operations through both clients and asserts equal results.
112
+
113
+ ## Limitations and parity notes
114
+
115
+ CLI invocation is the source of every limitation here — each call spawns a
116
+ `pebble` process, so there's more per-call overhead than the socket transport,
117
+ and some streaming is buffered rather than incremental.
118
+
119
+ A few methods can't fully match the socket client:
120
+
121
+ - `replan_services()`, `start_services()`, `stop_services()`, and
122
+ `restart_services()` return the change ID only when no timeout is set.
123
+ - `notify()` supports custom notices only (Pebble's CLI only exposes
124
+ `pebble notify` for custom notices).
125
+ - `abort_change()` raises `NotImplementedError`: the Pebble CLI exposes no
126
+ command to abort a change, so there is no way to back this through the CLI.
127
+ - `get_warnings()` and `ack_warnings()` raise `NotImplementedError`: warnings
128
+ are deprecated in Pebble (the warnings API has been removed and warnings are
129
+ now surfaced as notices). Use `get_notices()` / `get_notice()` instead.
130
+
131
+ `get_services()`, `get_checks()`, `list_files()`, `get_changes()`,
132
+ `get_change()`, and `get_identities()` use Pebble's structured `--format json`
133
+ output, so they return the same rich data as `ops.pebble.Client` (change
134
+ `kind`/`tasks`/`err`, check thresholds, real file ownership, local identity user
135
+ IDs). This requires a Pebble build that supports `--format` on read commands.
136
+
137
+ ## Comparison with `ops.pebble.Client`
138
+
139
+ | | `ops.pebble.Client` | `PebbleCliClient` |
140
+ |---|---|---|
141
+ | Transport | Unix socket | `pebble` CLI |
142
+ | Requires | Socket access | `pebble` binary |
143
+ | Performance | Higher | Moderate (per-call process spawn) |
144
+ | API | Native | 100% compatible |
145
+
146
+ ## Troubleshooting
147
+
148
+ **`Pebble binary not found`** — pass the full path:
149
+ `Client(pebble_binary="/snap/bin/pebble")`.
150
+
151
+ **`Connection error`** — confirm the daemon is up and `PEBBLE` points at its home
152
+ directory (or pass `socket_path=`); check `pebble version`.
153
+
154
+ **See the commands Shimmer runs** — enable debug logging:
155
+
156
+ ```python
157
+ import logging
158
+ logging.basicConfig(level=logging.DEBUG)
159
+ ```
160
+
161
+ ## More
162
+
163
+ - [CONTRIBUTING.md](CONTRIBUTING.md) — contribution guidelines
164
+ - [CHANGELOG.md](CHANGELOG.md) — version history
165
+ - Related: [ops](https://ops.readthedocs.io) ·
166
+ [pebble](https://documentation.ubuntu.com/pebble) · [juju](https://juju.is) ·
167
+ [charmcraft](https://canonical-charmcraft.readthedocs-hosted.com) ·
168
+ [rockcraft](https://documentation.ubuntu.com/rockcraft)
@@ -0,0 +1,142 @@
1
+ # Shimmer — a shiny Pebble client
2
+
3
+ A 100% compatible, drop-in replacement for `ops.pebble.Client` that drives
4
+ [Pebble](https://documentation.ubuntu.com/pebble) through its **CLI** instead of
5
+ the unix socket — for environments where the socket isn't reachable (such as a
6
+ Rock or a Juju container).
7
+
8
+ ![Shimmer parity demo](https://raw.githubusercontent.com/tonyandrewmeyer/shimmer/main/demo.gif)
9
+
10
+ <sub>The same deploy-and-verify routine run over `ops.pebble.Client` (unix
11
+ socket, left) and `shimmer.PebbleCliClient` (CLI, right) — identical results.</sub>
12
+
13
+ ## Overview
14
+
15
+ `PebbleCliClient` implements the same interface as `ops.pebble.Client`: same
16
+ method signatures, same return types, same raised exceptions. Under the hood it
17
+ translates each call into a `pebble` CLI command, parses the output back into the
18
+ same Python objects `ops` returns, and maps CLI errors onto the matching
19
+ exceptions. The contract is **parity** — code written against `ops.pebble.Client`
20
+ should run unchanged against Shimmer.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ # From PyPI
26
+ uv pip install pebble-shimmer
27
+
28
+ # Development version
29
+ git clone https://github.com/tonyandrewmeyer/shimmer
30
+ cd shimmer
31
+ uv pip install -e .
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Construct the client, then use it exactly like `ops.pebble.Client` — the methods,
37
+ arguments, return types, and exceptions are the same:
38
+
39
+ ```python
40
+ from shimmer import PebbleCliClient as Client
41
+
42
+ client = Client()
43
+ client.replan_services()
44
+ for service in client.get_services():
45
+ print(service.name, service.current.value)
46
+ ```
47
+
48
+ The whole point is that there's nothing new to learn: the full method surface is
49
+ documented by [`ops.pebble.Client`](https://ops.readthedocs.io/en/latest/reference/pebble.html).
50
+ Swapping `ops.pebble.Client` for `shimmer.PebbleCliClient` is the only change.
51
+
52
+ The constructor is where Shimmer differs, since it talks to a binary rather than
53
+ a socket:
54
+
55
+ ```python
56
+ client = Client(
57
+ socket_path="/var/lib/pebble/default/.pebble.socket", # sets PEBBLE / PEBBLE_SOCKET
58
+ pebble_binary="/snap/bin/pebble", # path to the pebble binary (default: "pebble")
59
+ timeout=5.0, # default per-command timeout in seconds
60
+ )
61
+ ```
62
+
63
+ `socket_path` doesn't open a socket — it points Shimmer at the daemon by setting
64
+ `PEBBLE` (its parent directory) and `PEBBLE_SOCKET` for the CLI. For drop-in
65
+ parity the constructor also accepts `opener` and `base_url`, but those only
66
+ configure the socket transport, so Shimmer accepts and ignores them. The
67
+ `ops.pebble` exceptions are re-exported from `shimmer` for convenience, but they
68
+ are the same objects, so `except ops.pebble.APIError` keeps working too.
69
+
70
+ ## Demo and verification
71
+
72
+ The GIF above is a recording of [`demo.md`](demo.md) — a
73
+ [Showboat](https://pypi.org/project/showboat/) document that runs one
74
+ deploy-and-verify routine against the **real socket client**, then the **same
75
+ code** against Shimmer, and `diff`s the two outputs to prove they're identical.
76
+ It's reproducible:
77
+
78
+ ```bash
79
+ uv run python demo.py # rebuild demo.md (verifies parity live)
80
+ uv run python demo.py --record # re-record demo.cast (needs tmux + asciinema)
81
+ agg demo.cast demo.gif # regenerate the GIF from the cast
82
+ ```
83
+
84
+ Parity is also exercised in CI by `tests/integration/test_parity.py`, which runs
85
+ the same operations through both clients and asserts equal results.
86
+
87
+ ## Limitations and parity notes
88
+
89
+ CLI invocation is the source of every limitation here — each call spawns a
90
+ `pebble` process, so there's more per-call overhead than the socket transport,
91
+ and some streaming is buffered rather than incremental.
92
+
93
+ A few methods can't fully match the socket client:
94
+
95
+ - `replan_services()`, `start_services()`, `stop_services()`, and
96
+ `restart_services()` return the change ID only when no timeout is set.
97
+ - `notify()` supports custom notices only (Pebble's CLI only exposes
98
+ `pebble notify` for custom notices).
99
+ - `abort_change()` raises `NotImplementedError`: the Pebble CLI exposes no
100
+ command to abort a change, so there is no way to back this through the CLI.
101
+ - `get_warnings()` and `ack_warnings()` raise `NotImplementedError`: warnings
102
+ are deprecated in Pebble (the warnings API has been removed and warnings are
103
+ now surfaced as notices). Use `get_notices()` / `get_notice()` instead.
104
+
105
+ `get_services()`, `get_checks()`, `list_files()`, `get_changes()`,
106
+ `get_change()`, and `get_identities()` use Pebble's structured `--format json`
107
+ output, so they return the same rich data as `ops.pebble.Client` (change
108
+ `kind`/`tasks`/`err`, check thresholds, real file ownership, local identity user
109
+ IDs). This requires a Pebble build that supports `--format` on read commands.
110
+
111
+ ## Comparison with `ops.pebble.Client`
112
+
113
+ | | `ops.pebble.Client` | `PebbleCliClient` |
114
+ |---|---|---|
115
+ | Transport | Unix socket | `pebble` CLI |
116
+ | Requires | Socket access | `pebble` binary |
117
+ | Performance | Higher | Moderate (per-call process spawn) |
118
+ | API | Native | 100% compatible |
119
+
120
+ ## Troubleshooting
121
+
122
+ **`Pebble binary not found`** — pass the full path:
123
+ `Client(pebble_binary="/snap/bin/pebble")`.
124
+
125
+ **`Connection error`** — confirm the daemon is up and `PEBBLE` points at its home
126
+ directory (or pass `socket_path=`); check `pebble version`.
127
+
128
+ **See the commands Shimmer runs** — enable debug logging:
129
+
130
+ ```python
131
+ import logging
132
+ logging.basicConfig(level=logging.DEBUG)
133
+ ```
134
+
135
+ ## More
136
+
137
+ - [CONTRIBUTING.md](CONTRIBUTING.md) — contribution guidelines
138
+ - [CHANGELOG.md](CHANGELOG.md) — version history
139
+ - Related: [ops](https://ops.readthedocs.io) ·
140
+ [pebble](https://documentation.ubuntu.com/pebble) · [juju](https://juju.is) ·
141
+ [charmcraft](https://canonical-charmcraft.readthedocs-hosted.com) ·
142
+ [rockcraft](https://documentation.ubuntu.com/rockcraft)