Skip to content

Commit aad1a10

Browse files
authored
Merge pull request #275 from jasonacox/v0.15.1
v0.15.1 - Code Quality and Build Pipeline Improvements
2 parents b66f840 + 126efc5 commit aad1a10

17 files changed

Lines changed: 454 additions & 1106 deletions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Check Protobuf
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.proto'
7+
- '**_pb2.py'
8+
pull_request:
9+
paths:
10+
- '**.proto'
11+
- '**_pb2.py'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
check-protobuf:
19+
name: "Verify pb2 files are up to date"
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Install pinned protobuf tools
30+
run: pip install -r tools/requirements-tools.txt
31+
32+
- name: Regenerate protobuf files
33+
run: bash tools/gen_proto.sh
34+
35+
- name: Check for uncommitted changes
36+
run: |
37+
git diff --exit-code -- '**/*_pb2.py' || {
38+
echo ""
39+
echo "ERROR: pb2 files are out of date with their .proto sources."
40+
echo "Run the protoc commands above locally and commit the updated pb2 files."
41+
exit 1
42+
}

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: protoc-gen
5+
name: Regenerate protobuf Python files
6+
language: script
7+
entry: tools/gen_proto.sh
8+
files: \.proto$
9+
pass_filenames: false
10+
# Requires: pip install -r tools/requirements-tools.txt
11+
12+
- id: pylint-pypowerwall
13+
name: Pylint (pypowerwall errors)
14+
language: system
15+
entry: pylint -E pypowerwall/
16+
files: ^pypowerwall/.*\.py$
17+
pass_filenames: false
18+
19+
- id: pylint-proxy
20+
name: Pylint (proxy errors)
21+
language: system
22+
entry: pylint -E proxy/*.py
23+
files: ^proxy/.*\.py$
24+
pass_filenames: false

.pylintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[MASTER]
2+
# Ignore auto-generated protobuf files
3+
ignore-paths = .*_pb2\.py$
4+
15
[MESSAGES CONTROL]
26
disable=consider-iterating-dictionary, consider-swap-variables, consider-using-enumerate, cyclic-import, consider-using-max-builtin, no-else-continue, consider-using-min-builtin, consider-using-in, super-with-arguments, protected-access, import-outside-toplevel, multiple-statements, unidiomatic-typecheck, no-else-break, import-error, invalid-name, missing-docstring, no-else-return, no-member, too-many-lines, line-too-long, too-many-ancestors, too-many-arguments, too-many-branches, too-many-instance-attributes, too-many-locals, too-many-nested-blocks, too-many-return-statements, too-many-statements, too-few-public-methods, ungrouped-imports, use-dict-literal, superfluous-parens, fixme, consider-using-f-string, bare-except, broad-except, unused-variable, unspecified-encoding, redefined-builtin, consider-using-dict-items, redundant-u-string-prefix, useless-object-inheritance, wrong-import-position, logging-not-lazy, logging-fstring-interpolation, wildcard-import, logging-format-interpolation
37

RELEASE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# RELEASE NOTES
22

3+
## v0.15.1 - Code Quality and Build Pipeline Improvements
4+
5+
* Fix: Remove duplicate stub methods `get_grid_charging()` and `get_grid_export()` in `pypowerwall_tedapi.py` that were left over from a merge — the real implementations (reading/writing config via v1r transport) were already present and being shadowed
6+
* Fix: Update `pwsimulator` `stub.py` to use `ssl.SSLContext` API replacing the removed `ssl.wrap_socket()` call, which caused the simulator container to silently exit on Python 3.12+
7+
* Fix: Remove `linux/arm/v7` platform from `pwsimulator` Docker build (`upload.sh`) — platform is no longer supported
8+
* Fix: Correct protobuf runtime dependency — `protobuf>=3.20.0` was misleading; pb2 files generated with 4.25.x require `protobuf>=4.25.1,<5`
9+
* Add: `.pylintrc` with `[MESSAGES CONTROL]` disable list (restored), `[SIMILARITIES]` config, and `ignore-paths` to skip auto-generated `*_pb2.py` files
10+
* Add: `tools/gen_proto.sh` — script to regenerate all `*_pb2.py` files from `.proto` sources using pinned `grpcio-tools`
11+
* Add: `tools/requirements-tools.txt` — pinned dev tools (`grpcio-tools<1.64`, `protobuf<5`) to ensure pb2 files are generated consistently with a compatible protobuf version
12+
* Add: `.pre-commit-config.yaml` — pre-commit hooks for protobuf regeneration and `pylint -E` checks on `pypowerwall/` and `proxy/` before every commit
13+
* Add: `.github/workflows/check-protobuf.yml` — CI workflow to verify committed `*_pb2.py` files are in sync with their `.proto` sources
14+
315
## v0.15.0 - Powerwall 3 Wired LAN TEDAPI Support (v1r)
416

517
* Docs: Note FleetAPI/Cloud mode requirement for `get_grid_charging()` and `get_grid_export()` - by @jasonacox-sam in https://github.com/jasonacox/pypowerwall/pull/268

proxy/.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ tedapi_rsa_*
1919
upload.sh
2020
upload-beta.sh
2121
.beta_version
22-
beta.txt
2322
perf_test.py
2423
localtest.sh
2524
testproxy.sh

proxy/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pypowerwall==0.15.0
1+
pypowerwall==0.15.1
22
bs4==0.0.2

pwsimulator/stub.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
print("Warning: tedapi_pb2 not found - TEDAPI protobuf support disabled", flush=True)
3939
TEDAPI_ENABLED = False
4040

41-
version_tuple = (0, 2, 4)
41+
version_tuple = (0, 2, 5)
4242
version = __version__ = '%d.%d.%d' % version_tuple
4343
__author__ = 'jasonacox'
4444

@@ -727,13 +727,11 @@ def do_test_endpoint(self):
727727

728728
# noinspection PyBroadException
729729
try:
730-
# noinspection PyTypeChecker
731730
with ThreadingHTTPServer(server_address, Handler) as server:
732-
server.socket = ssl.wrap_socket(server.socket,
733-
server_side=True,
734-
certfile='localhost.pem',
735-
ssl_version=ssl.PROTOCOL_TLS)
731+
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
732+
context.load_cert_chain(certfile='localhost.pem')
733+
server.socket = context.wrap_socket(server.socket, server_side=True)
736734
print("Server configured to handle multiple simultaneous connections", flush=True)
737735
server.serve_forever()
738-
except Exception:
739-
print(' CANCEL \n')
736+
except Exception as e:
737+
print(f' CANCEL: {e}\n')

pypowerwall/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
from json import JSONDecodeError
9090
from typing import Optional, Union
9191

92-
version_tuple = (0, 15, 0)
92+
version_tuple = (0, 15, 1)
9393
version = __version__ = '%d.%d.%d' % version_tuple
9494
__author__ = 'jasonacox'
9595

pypowerwall/local/tesla_pb2.py

Lines changed: 202 additions & 979 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pypowerwall/tedapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def schedule_max_backup(self, duration_seconds=7200):
464464
try:
465465
# Must cancel any existing (active or expired) before scheduling new
466466
self.cancel_max_backup()
467-
from google.protobuf.timestamp_pb2 import Timestamp
467+
from google.protobuf.timestamp_pb2 import Timestamp # pylint: disable=no-name-in-module
468468
teg = combined_pb2.TEGMessages()
469469
req = teg.schedule_manual_backup_event_request
470470
req.scheduling_info.start_time.CopyFrom(Timestamp(seconds=int(time.time())))

0 commit comments

Comments
 (0)