mirror of
https://github.com/meshtastic/python.git
synced 2025-12-28 10:27:54 -05:00
Compare commits
4 Commits
ble-loggin
...
1.2.89
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c016176520 | ||
|
|
e6999ba5ad | ||
|
|
5590dbeb6f | ||
|
|
e8a2909173 |
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -8,6 +8,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.get_version.outputs.version }}
|
version: ${{ steps.get_version.outputs.version }}
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
new_sha: ${{ steps.commit_updated.outputs.sha }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@@ -19,12 +20,14 @@ jobs:
|
|||||||
bin/bump_version.py
|
bin/bump_version.py
|
||||||
|
|
||||||
- name: Commit updated version.py
|
- name: Commit updated version.py
|
||||||
|
id: commit_updated
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'github-actions'
|
git config --global user.name 'github-actions'
|
||||||
git config --global user.email 'bot@noreply.github.com'
|
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 remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
||||||
git add setup.py
|
git add setup.py
|
||||||
git commit -m "bump version" && git push || echo "No changes to commit"
|
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
|
- name: Get version
|
||||||
id: get_version
|
id: get_version
|
||||||
@@ -45,9 +48,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
@@ -82,7 +82,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ needs.release_create.outputs.new_sha }}
|
||||||
|
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
@@ -127,7 +129,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ needs.release_create.outputs.new_sha }}
|
||||||
|
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
@@ -167,7 +171,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ needs.release_create.outputs.new_sha }}
|
||||||
|
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
|
|||||||
6
examples/show_ports.py
Normal file
6
examples/show_ports.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
"""Simple program to show serial ports.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from meshtastic.util import findPorts
|
||||||
|
|
||||||
|
print(findPorts())
|
||||||
@@ -264,6 +264,22 @@ def test_findPorts_when_duplicate_found_and_duplicate_option_used(patch_comports
|
|||||||
patch_comports.assert_called()
|
patch_comports.assert_called()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unitslow
|
||||||
|
@patch('serial.tools.list_ports.comports')
|
||||||
|
def test_findPorts_when_duplicate_found_and_duplicate_option_used_ports_reversed(patch_comports):
|
||||||
|
"""Test findPorts()"""
|
||||||
|
class TempPort:
|
||||||
|
""" temp class for port"""
|
||||||
|
def __init__(self, device=None, vid=None):
|
||||||
|
self.device = device
|
||||||
|
self.vid = vid
|
||||||
|
fake1 = TempPort('/dev/cu.usbserial-1430', vid='fake1')
|
||||||
|
fake2 = TempPort('/dev/cu.wchusbserial1430', vid='fake2')
|
||||||
|
patch_comports.return_value = [fake2, fake1]
|
||||||
|
assert findPorts(eliminate_duplicates=True) == ['/dev/cu.wchusbserial1430']
|
||||||
|
patch_comports.assert_called()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unitslow
|
@pytest.mark.unitslow
|
||||||
@patch('serial.tools.list_ports.comports')
|
@patch('serial.tools.list_ports.comports')
|
||||||
def test_findPorts_when_duplicate_found_and_duplicate_option_not_used(patch_comports):
|
def test_findPorts_when_duplicate_found_and_duplicate_option_not_used(patch_comports):
|
||||||
@@ -315,8 +331,11 @@ def test_eliminate_duplicate_port():
|
|||||||
assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1']) == ['/dev/fake', '/dev/fake1']
|
assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1']) == ['/dev/fake', '/dev/fake1']
|
||||||
assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1', '/dev/fake2']) == ['/dev/fake', '/dev/fake1', '/dev/fake2']
|
assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1', '/dev/fake2']) == ['/dev/fake', '/dev/fake1', '/dev/fake2']
|
||||||
assert eliminate_duplicate_port(['/dev/cu.usbserial-1430', '/dev/cu.wchusbserial1430']) == ['/dev/cu.wchusbserial1430']
|
assert eliminate_duplicate_port(['/dev/cu.usbserial-1430', '/dev/cu.wchusbserial1430']) == ['/dev/cu.wchusbserial1430']
|
||||||
|
assert eliminate_duplicate_port(['/dev/cu.wchusbserial1430', '/dev/cu.usbserial-1430']) == ['/dev/cu.wchusbserial1430']
|
||||||
assert eliminate_duplicate_port(['/dev/cu.SLAB_USBtoUART', '/dev/cu.usbserial-0001']) == ['/dev/cu.usbserial-0001']
|
assert eliminate_duplicate_port(['/dev/cu.SLAB_USBtoUART', '/dev/cu.usbserial-0001']) == ['/dev/cu.usbserial-0001']
|
||||||
|
assert eliminate_duplicate_port(['/dev/cu.usbserial-0001', '/dev/cu.SLAB_USBtoUART']) == ['/dev/cu.usbserial-0001']
|
||||||
assert eliminate_duplicate_port(['/dev/cu.usbmodem11301', '/dev/cu.wchusbserial11301']) == ['/dev/cu.wchusbserial11301']
|
assert eliminate_duplicate_port(['/dev/cu.usbmodem11301', '/dev/cu.wchusbserial11301']) == ['/dev/cu.wchusbserial11301']
|
||||||
|
assert eliminate_duplicate_port(['/dev/cu.wchusbserial11301', '/dev/cu.usbmodem11301']) == ['/dev/cu.wchusbserial11301']
|
||||||
|
|
||||||
@patch('platform.version', return_value='10.0.22000.194')
|
@patch('platform.version', return_value='10.0.22000.194')
|
||||||
@patch('platform.release', return_value='10')
|
@patch('platform.release', return_value='10')
|
||||||
|
|||||||
@@ -401,6 +401,7 @@ def eliminate_duplicate_port(ports):
|
|||||||
if len(ports) != 2:
|
if len(ports) != 2:
|
||||||
new_ports = ports
|
new_ports = ports
|
||||||
else:
|
else:
|
||||||
|
ports.sort()
|
||||||
if 'usbserial' in ports[0] and 'wchusbserial' in ports[1]:
|
if 'usbserial' in ports[0] and 'wchusbserial' in ports[1]:
|
||||||
first = ports[0].replace("usbserial-", "")
|
first = ports[0].replace("usbserial-", "")
|
||||||
second = ports[1].replace("wchusbserial", "")
|
second = ports[1].replace("wchusbserial", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user