Skip to content

Commit 10c2e75

Browse files
committed
fix tests imports, add sed for fixing pb2 imports
1 parent 769c99e commit 10c2e75

16 files changed

Lines changed: 136 additions & 129 deletions

bin/regen-protobufs.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
./nanopb-0.4.7/generator-bin/protoc -I=protobufs --python_out ./ ./protobufs/meshtastic/*.proto
88

99
# workaround for import bug in protoc https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-690618628
10+
mv ./meshtastic/*_pb2.py ./meshtastic/pbDefinitions
1011

1112
if [[ $OSTYPE == 'darwin'* ]]; then
12-
sed -i '' -E 's/^(import.*_pb2)/from . \1/' meshtastic/*.py
13+
sed -i '' -E 's/^(import.*_pb2)/from . \1/' meshtastic/pbDefinitions/*.py
1314
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
14-
sed -i '' -E "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
15+
sed -i '' -E "s/^None = 0/globals()['None'] = 0/" meshtastic/pbDefinitions/mesh_pb2.py
16+
# change from meshtastic to meshtastic.pbDefinitions
17+
sed -i -E 's/^from meshtastic(.*_pb2.*)/from meshtastic.pbDefinitions\1/' meshtastic/pbDefinitions/*.py
1518
else
16-
sed -i -e 's/^import.*_pb2/from . \0/' meshtastic/*.py
19+
sed -i -e 's/^import.*_pb2/from . \0/' meshtastic/pbDefinitions/*.py
1720
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
18-
sed -i -e "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
21+
sed -i -e "s/^None = 0/globals()['None'] = 0/" meshtastic/pbDefinitions/mesh_pb2.py
22+
# change from meshtastic to meshtastic.pbDefinitions
23+
sed -i -E 's/^from meshtastic(.*_pb2.*)/from meshtastic.pbDefinitions\1/' meshtastic/pbDefinitions/*.py
1924
fi

meshtastic/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
8686
mesh_pb2,
8787
portnums_pb2,
8888
remote_hardware_pb2,
89-
util,
9089
)
9190
from meshtastic.node import Node
9291
from meshtastic.pbDefinitions import telemetry_pb2

meshtastic/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
import meshtastic.test
1919
import meshtastic.util
20-
from meshtastic.pbDefinitions import channel_pb2, config_pb2, portnums_pb2, remote_hardware
20+
from meshtastic.pbDefinitions import channel_pb2, config_pb2, portnums_pb2
21+
from meshtastic import remote_hardware
2122
from meshtastic.__init__ import BROADCAST_ADDR
2223
from meshtastic.ble_interface import BLEInterface
2324
from meshtastic.globals import Globals

meshtastic/pbDefinitions/admin_pb2.py

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

meshtastic/pbDefinitions/apponly_pb2.py

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

meshtastic/pbDefinitions/atak_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meshtastic/pbDefinitions/channel_pb2.py

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

meshtastic/pbDefinitions/clientonly_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)