mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-18 07:36:34 -05:00
Added pre-commit hooks
This patch adds pre-commit hook support to ensure code passes basic checks prior to allowing a commit.
This commit is contained in:
parent
8bd8b95b35
commit
75f610d971
18
.pre-commit-config.yaml
Normal file
18
.pre-commit-config.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 19.3b0
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.8.1
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [flake8-bugbear]
|
@ -4,6 +4,8 @@ CHANGES
|
||||
v1.5.0
|
||||
------
|
||||
|
||||
* Added pre-commit hooks
|
||||
* Update Changelog for v1.5.0
|
||||
* Added QueryPlugin resend all delayed msgs or Flush
|
||||
* Added QueryPlugin
|
||||
* Added support to save/load MsgTrack on exit/start
|
||||
|
@ -17,7 +17,7 @@ cd ~/.venv_aprsd
|
||||
|
||||
./bin/aprsd # generates a config.yml template on first run
|
||||
|
||||
vi ~/.aprsd/config.yml
|
||||
vi ~/.aprsd/config.yml
|
||||
|
||||
./bin/aprsd
|
||||
|
||||
|
15
README.rst
15
README.rst
@ -17,7 +17,7 @@ Listen on amateur radio aprs-is network for messages and respond to them.
|
||||
You must have an amateur radio callsign to use this software. APRSD gets
|
||||
messages for the configured HAM callsign, and sends those messages to a
|
||||
list of plugins for processing. There are a set of core plugins that
|
||||
provide responding to messages to check email, get location, ping,
|
||||
provide responding to messages to check email, get location, ping,
|
||||
time of day, get weather, and fortune telling as well as version information
|
||||
of aprsd itself.
|
||||
|
||||
@ -25,7 +25,7 @@ Typical use case
|
||||
================
|
||||
|
||||
Ham radio operator using an APRS enabled HAM radio sends a message to check
|
||||
the weather. an APRS message is sent, and then picked up by APRSD. The
|
||||
the weather. an APRS message is sent, and then picked up by APRSD. The
|
||||
APRS packet is decoded, and the message is sent through the list of plugins
|
||||
for processing. The WeatherPlugin picks up the message, fetches the weather
|
||||
for the area around the user who sent the request, and then responds with
|
||||
@ -38,7 +38,7 @@ APRSD Capabilities
|
||||
|
||||
* server - The main aprsd server processor. Send/Rx APRS messages to HAM callsign
|
||||
* send-message - use aprsd to send a command/message to aprsd server. Used for development testing
|
||||
* sample-config - generate a sample aprsd.yml config file for use/editing
|
||||
* sample-config - generate a sample aprsd.yml config file for use/editing
|
||||
* bash completion generation. Uses python click bash completion to generate completion code for your .bashrc/.zshrc
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ Output
|
||||
server
|
||||
======
|
||||
|
||||
This is the main server command that will listen to APRS-IS servers and
|
||||
This is the main server command that will listen to APRS-IS servers and
|
||||
look for incomming commands to the callsign configured in the config file
|
||||
|
||||
::
|
||||
@ -319,12 +319,12 @@ LOCATION
|
||||
|
||||
Sending message_______________ 7(Tx3)
|
||||
Raw : KM6XXX-9>APRS::KM6XXX :8 Miles NE Auburn CA 1673' 39.91150,-120.93450 0.1h ago{7
|
||||
To : KM6XXX
|
||||
To : KM6XXX
|
||||
Message : 8 Miles E Auburn CA 1673' 38.91150,-120.93450 0.1h ago
|
||||
|
||||
Sending ack __________________ Tx(3)
|
||||
Raw : KM6XXX-9>APRS::KM6XXX :ack28
|
||||
To : KM6XXX
|
||||
To : KM6XXX
|
||||
Ack number : 28
|
||||
|
||||
Received message______________
|
||||
@ -356,7 +356,7 @@ Release
|
||||
|
||||
To do release to pypi:
|
||||
|
||||
* Tag release with
|
||||
* Tag release with
|
||||
|
||||
git tag -v1.XX -m "New release"
|
||||
|
||||
@ -414,4 +414,3 @@ Provide a csv list of pypi installable plugins. Then make sure the plugin
|
||||
python file is in your /plugins volume and the plugin will be installed at
|
||||
container startup. The plugin may have dependencies that are required.
|
||||
The plugin file should be copied to /plugins for loading by aprsd
|
||||
|
||||
|
@ -383,10 +383,7 @@ def server(loglevel, quiet, disable_validation, config_file, flush):
|
||||
|
||||
rx_msg_queue = queue.Queue(maxsize=20)
|
||||
tx_msg_queue = queue.Queue(maxsize=20)
|
||||
msg_queues = {
|
||||
"rx": rx_msg_queue,
|
||||
"tx": tx_msg_queue,
|
||||
}
|
||||
msg_queues = {"rx": rx_msg_queue, "tx": tx_msg_queue}
|
||||
|
||||
rx_thread = threads.APRSDRXThread(msg_queues=msg_queues, config=config)
|
||||
tx_thread = threads.APRSDTXThread(msg_queues=msg_queues, config=config)
|
||||
|
@ -217,10 +217,7 @@ class TextMessage(Message):
|
||||
def __repr__(self):
|
||||
"""Build raw string to send over the air."""
|
||||
return "{}>APRS::{}:{}{{{}\n".format(
|
||||
self.fromcall,
|
||||
self.tocall.ljust(9),
|
||||
self._filter_for_send(),
|
||||
str(self.id),
|
||||
self.fromcall, self.tocall.ljust(9), self._filter_for_send(), str(self.id)
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -70,7 +70,7 @@ class PluginManager(object):
|
||||
|
||||
self.obj_list = []
|
||||
|
||||
for path, subdirs, files in os.walk(dir_path):
|
||||
for path, _subdirs, files in os.walk(dir_path):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, pattern):
|
||||
LOG.debug("MODULE? '{}' '{}'".format(name, path))
|
||||
|
@ -2,8 +2,6 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
from aprsd import email
|
||||
|
||||
if sys.version_info >= (3, 2):
|
||||
@ -12,7 +10,7 @@ else:
|
||||
import mock
|
||||
|
||||
|
||||
class testMain(unittest.TestCase):
|
||||
class TestMain(unittest.TestCase):
|
||||
@mock.patch("aprsd.email._imap_connect")
|
||||
@mock.patch("aprsd.email._smtp_connect")
|
||||
def test_validate_email(self, imap_mock, smtp_mock):
|
||||
|
@ -1,16 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
import aprsd
|
||||
from aprsd import plugin
|
||||
from aprsd.fuzzyclock import fuzzy
|
||||
|
||||
|
||||
class testPlugin(unittest.TestCase):
|
||||
class TestPlugin(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.fromcall = "KFART"
|
||||
self.ack = 1
|
||||
@ -41,11 +38,11 @@ class testPlugin(unittest.TestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch("time.localtime")
|
||||
def test_Time(self, mock_time):
|
||||
def test_time(self, mock_time):
|
||||
fake_time = mock.MagicMock()
|
||||
h = fake_time.tm_hour = 16
|
||||
m = fake_time.tm_min = 12
|
||||
s = fake_time.tm_sec = 55
|
||||
fake_time.tm_sec = 55
|
||||
mock_time.return_value = fake_time
|
||||
time_plugin = plugin.TimePlugin(self.config)
|
||||
|
||||
@ -66,7 +63,7 @@ class testPlugin(unittest.TestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch("time.localtime")
|
||||
def test_Ping(self, mock_time):
|
||||
def test_ping(self, mock_time):
|
||||
fake_time = mock.MagicMock()
|
||||
h = fake_time.tm_hour = 16
|
||||
m = fake_time.tm_min = 12
|
||||
|
4
tox.ini
4
tox.ini
@ -28,7 +28,7 @@ commands = sphinx-build -b html docs/source docs/html
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
flake8 {posargs} aprsd
|
||||
flake8 {posargs} aprsd tests
|
||||
|
||||
[testenv:fast8]
|
||||
basepython = python3
|
||||
@ -43,7 +43,7 @@ skip_install = true
|
||||
deps =
|
||||
-r{toxinidir}/dev-requirements.txt
|
||||
commands =
|
||||
flake8 aprsd
|
||||
flake8 aprsd tests
|
||||
|
||||
[flake8]
|
||||
max-line-length = 99
|
||||
|
Loading…
Reference in New Issue
Block a user