Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
*.{sh,[sS][hH]} text eol=lf
14 changes: 7 additions & 7 deletions .github/workflows/cleanup_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Remove old artifacts
on:
schedule:
# Every day at 1am
- cron: '0 1 * * *'
- cron: "0 1 * * *"

workflow_dispatch:

jobs:
Expand All @@ -13,8 +13,8 @@ jobs:
timeout-minutes: 10

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: '1 month'
skip-tags: true
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: "1 month"
skip-tags: true
125 changes: 60 additions & 65 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,76 +11,73 @@ jobs:
new_sha: ${{ steps.commit_updated.outputs.sha }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Bump version
run: >-
bin/bump_version.py

- name: Commit updated version.py
id: commit_updated
run: |
git config --global user.name 'github-actions'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add setup.py
git commit -m "bump version" && git push || echo "No changes to commit"
git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'

- name: Get version
id: get_version
run: >-
bin/show_version.py

- name: Create GitHub release
uses: actions/create-release@v1
id: create_release

with:
draft: true
prerelease: true
release_name: Meshtastic Python ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
body: |
Autogenerated by github action, developer should edit as required before publishing...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v2

- name: Bump version
run: >-
bin/bump_version.py

- name: Commit updated version.py
id: commit_updated
run: |
git config --global user.name 'github-actions'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add setup.py
git commit -m "bump version" && git push || echo "No changes to commit"
git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}'

- name: Get version
id: get_version
run: >-
bin/show_version.py

- name: Create GitHub release
uses: actions/create-release@v1
id: create_release

with:
draft: true
prerelease: true
release_name: Meshtastic Python ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
body: |
Autogenerated by github action, developer should edit as required before publishing...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install pypa/build
run: >-
python -m
pip install
build
--user

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install pypa/build
run: >-
python -m
pip install
build
--user

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

build-and-publish-mac:
runs-on: macos-latest
needs: release_create
steps:

- name: Checkout
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -127,7 +124,6 @@ jobs:
runs-on: ubuntu-latest
needs: release_create
steps:

- name: Checkout
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -169,7 +165,6 @@ jobs:
runs-on: windows-latest
needs: release_create
steps:

- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
7 changes: 7 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*out
*logs
*actions
*notifications
plugins
user_trunk.yaml
user.yaml
2 changes: 2 additions & 0 deletions .trunk/configs/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
10 changes: 10 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "D4", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
39 changes: 39 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 0.1
cli:
version: 1.7.0
plugins:
sources:
- id: trunk
ref: v0.0.14
uri: https://github.com/trunk-io/plugins
lint:
ignore:
- linters: [ALL]
paths:
# Ignore generated files
- meshtastic/*_pb2.py
enabled:
- actionlint@1.6.23
- black@23.3.0
- git-diff-check
- gitleaks@8.16.2
- isort@5.12.0
- markdownlint@0.33.0
- prettier@2.8.7
- pylint@2.17.1
- ruff@0.0.260
- shellcheck@0.9.0
- shfmt@3.5.0
- yamllint@1.30.0
runtimes:
enabled:
- go@1.19.5
- node@18.12.1
- python@3.10.8
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
12 changes: 7 additions & 5 deletions bin/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@

lines = None

with open(version_filename, 'r', encoding='utf-8') as f:
with open(version_filename, "r", encoding="utf-8") as f:
lines = f.readlines()

with open(version_filename, 'w', encoding='utf-8') as f:
with open(version_filename, "w", encoding="utf-8") as f:
for line in lines:
if line.lstrip().startswith("version="):
# get rid of quotes around the version
line = line.replace('"', '')
line = line.replace('"', "")
# get rid of trailing comma
line = line.replace(",", "")
# split on '='
words = line.split("=")
# split the version into parts (by period)
v = words[1].split(".")
build_num = re.findall(r"\d+", v[2])[0]
new_build_num = str(int(build_num)+1)
ver = f'{v[0]}.{v[1]}.{v[2].replace(build_num, new_build_num)}'.replace('\n', '')
new_build_num = str(int(build_num) + 1)
ver = f"{v[0]}.{v[1]}.{v[2].replace(build_num, new_build_num)}".replace(
"\n", ""
)
f.write(f' version="{ver}",\n')
else:
f.write(line)
12 changes: 6 additions & 6 deletions bin/regen-protobufs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# workaround for import bug in protoc https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-690618628

if [[ $OSTYPE == 'darwin'* ]]; then
sed -i '' -E 's/^(import.*_pb2)/from . \1/' meshtastic/*.py
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
sed -i '' -E "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
sed -i '' -E 's/^(import.*_pb2)/from . \1/' meshtastic/*.py
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
sed -i '' -E "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
else
sed -i -e 's/^import.*_pb2/from . \0/' meshtastic/*.py
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
sed -i -e "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
sed -i -e 's/^import.*_pb2/from . \0/' meshtastic/*.py
# automate the current workaround (may be related to Meshtastic-protobufs issue #27 https://github.com/meshtastic/protobufs/issues/27)
sed -i -e "s/^None = 0/globals()['None'] = 0/" meshtastic/mesh_pb2.py
fi
8 changes: 4 additions & 4 deletions bin/show_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

lines = None

with open(version_filename, 'r', encoding='utf-8') as f:
with open(version_filename, "r", encoding="utf-8") as f:
lines = f.readlines()

for line in lines:
if line.lstrip().startswith("version="):
# get rid of quotes around the version
line2 = line.replace('"', '')
line2 = line.replace('"', "")
# get rid of the trailing comma
line2 = line2.replace(',', '')
line2 = line2.replace(",", "")
# split on =
words = line2.split("=")
# Note: This format is for github actions
print(f'::set-output name=version::{words[1].strip()}')
print(f"::set-output name=version::{words[1].strip()}")
2 changes: 1 addition & 1 deletion bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ python3 setup.py sdist bdist_wheel
python3 -m twine check dist/*
# test the upload
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
echo "view the upload at https://test.pypi.org/ it it looks good upload for real"
echo "view the upload at https://test.pypi.org/ it it looks good upload for real"
2 changes: 1 addition & 1 deletion exampleConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ location:

userPrefs:
region: 1
isAlwaysPowered: 'true'
isAlwaysPowered: "true"
screenOnSecs: 31536000
waitBluetoothSecs: 31536000
4 changes: 2 additions & 2 deletions example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ location:
lon: -93.88888
alt: 304

config:
config:
bluetooth:
enabled: true
fixedPin: 123456
Expand All @@ -36,7 +36,7 @@ config:
meshSdsTimeoutSecs: 7200
minWakeSecs: 10
sdsSecs: 4294967295

module_config:
telemetry:
deviceUpdateInterval: 900
Expand Down
5 changes: 3 additions & 2 deletions examples/get_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import sys

import meshtastic
import meshtastic.serial_interface

Expand All @@ -15,6 +16,6 @@
iface = meshtastic.serial_interface.SerialInterface()
if iface.nodes:
for n in iface.nodes.values():
if n['num'] == iface.myInfo.my_node_num:
print(n['user']['hwModel'])
if n["num"] == iface.myInfo.my_node_num:
print(n["user"]["hwModel"])
iface.close()
1 change: 1 addition & 0 deletions examples/hello_world_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import sys

import meshtastic
import meshtastic.serial_interface

Expand Down
Loading