1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-09-05 22:57:52 -04:00

Compare commits

...

5 Commits

Author SHA1 Message Date
935f820271 Removed Makefile comment. 2022-12-07 14:23:35 -05:00
576301ca20 Update Makefile for dev vs. run environments
This patch updates the Makefile to allow for creating
development vs runtime python virtual environments.

If you only want to run aprsd commands
make run

If you want to work on aprsd code
make dev
2022-12-07 14:19:42 -05:00
6d34d9c514 Added pyopenssl for https for webchat
In order for webchat to support fetching the GPS location in the
browser, the conenction from the browser needs to be https://
2022-12-07 14:03:25 -05:00
deeee71f8f
Merge pull request #103 from craigerl/user-agents
change from device-detector to user-agents
2022-12-07 13:59:26 -05:00
f2b1ad35f9 change from device-detector to user-agents
the device detector was taking 1 minute on a raspi to parse out the
user-agent string from the browser.  user-agents takes 2 seconds,
which still isn't great, but 'doable' for the webchat interface.
2022-12-07 13:40:08 -05:00
5 changed files with 42 additions and 26 deletions

View File

@ -1,4 +1,3 @@
REQUIREMENTS_TXT ?= requirements.txt dev-requirements.txt
WORKDIR?=.
VENVDIR ?= $(WORKDIR)/.aprsd-venv
@ -18,7 +17,10 @@ Makefile.venv:
help: # Help for the Makefile
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
dev: venv ## Create the virtualenv with all the requirements installed
dev: REQUIREMENTS_TXT = requirements.txt dev-requirements.txt
dev: venv ## Create a python virtual environment for development of aprsd
run: venv ## Create a virtual environment for running aprsd commands
docs: build
cp README.rst docs/readme.rst

View File

@ -9,13 +9,13 @@ import time
from aprslib import util as aprslib_util
import click
from device_detector import DeviceDetector
import flask
from flask import request
from flask.logging import default_handler
import flask_classful
from flask_httpauth import HTTPBasicAuth
from flask_socketio import Namespace, SocketIO
from user_agents import parse as ua_parse
from werkzeug.security import check_password_hash, generate_password_hash
import wrapt
@ -237,10 +237,16 @@ class WebChatFlask(flask_classful.FlaskView):
)
)
elif transport == client.TRANSPORT_SERIALKISS:
# for pep8 violation
kiss_default = aprsd_config.DEFAULT_DATE_FORMAT["kiss"]
default_baudrate = kiss_default["serial"]["baudrate"]
aprs_connection = (
"SerialKISS://{}@{} baud".format(
self.config["kiss"]["serial"]["device"],
self.config["kiss"]["serial"]["baudrate"],
self.config["kiss"]["serial"].get(
"baudrate",
default_baudrate,
),
)
)
@ -248,13 +254,13 @@ class WebChatFlask(flask_classful.FlaskView):
@auth.login_required
def index(self):
user_agent = request.headers.get("User-Agent")
device = DeviceDetector(user_agent).parse()
LOG.debug(f"Device type {device.device_type()}")
LOG.debug(f"Is mobile? {device.is_mobile()}")
ua_str = request.headers.get("User-Agent")
# this takes about 2 seconds :(
user_agent = ua_parse(ua_str)
LOG.debug(f"Is mobile? {user_agent.is_mobile}")
stats = self._stats()
if device.is_mobile():
if user_agent.is_mobile:
html_template = "mobile.html"
else:
html_template = "index.html"
@ -549,6 +555,7 @@ def webchat(ctx, flush, port):
LOG.info("Start socketio.run()")
socketio.run(
app,
ssl_context="adhoc",
host=config["aprsd"]["web"]["host"],
port=port,
)

View File

@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --annotation-style=line --resolver=backtracking dev-requirements.in
#
@ -11,10 +11,13 @@ autoflake==1.5.3 # via gray
babel==2.11.0 # via sphinx
black==22.10.0 # via gray
build==0.9.0 # via pip-tools
cachetools==5.2.0 # via tox
certifi==2022.9.24 # via requests
cfgv==3.3.1 # via pre-commit
chardet==5.1.0 # via tox
charset-normalizer==2.1.1 # via requests
click==8.1.3 # via black, pip-tools
colorama==0.4.6 # via tox
commonmark==0.9.1 # via rich
configargparse==1.5.3 # via gray
coverage[toml]==6.5.0 # via pytest-cov
@ -29,7 +32,7 @@ identify==2.5.9 # via pre-commit
idna==3.4 # via requests
imagesize==1.4.1 # via sphinx
importlib-metadata==5.1.0 # via sphinx
importlib-resources==5.10.0 # via fixit
importlib-resources==5.10.1 # via fixit
iniconfig==1.1.1 # via pytest
isort==5.10.1 # via -r dev-requirements.in, gray
jinja2==3.1.2 # via sphinx
@ -40,28 +43,27 @@ mccabe==0.7.0 # via flake8
mypy==0.991 # via -r dev-requirements.in
mypy-extensions==0.4.3 # via black, mypy, typing-inspect
nodeenv==1.7.0 # via pre-commit
packaging==21.3 # via build, pytest, sphinx, tox
packaging==21.3 # via build, pyproject-api, pytest, sphinx, tox
pathspec==0.10.2 # via black
pep517==0.13.0 # via build
pep8-naming==0.13.2 # via -r dev-requirements.in
pip-tools==6.11.0 # via -r dev-requirements.in
platformdirs==2.5.4 # via black, virtualenv
platformdirs==2.6.0 # via black, tox, virtualenv
pluggy==1.0.0 # via pytest, tox
pre-commit==2.20.0 # via -r dev-requirements.in
py==1.11.0 # via tox
pycodestyle==2.10.0 # via flake8
pyflakes==3.0.1 # via autoflake, flake8
pygments==2.13.0 # via rich, sphinx
pyparsing==3.0.9 # via packaging
pyproject-api==1.2.1 # via tox
pyrsistent==0.19.2 # via jsonschema
pytest==7.2.0 # via -r dev-requirements.in, pytest-cov
pytest-cov==4.0.0 # via -r dev-requirements.in
pytz==2022.6 # via babel
pyupgrade==3.3.0 # via gray
pyupgrade==3.3.1 # via gray
pyyaml==6.0 # via fixit, libcst, pre-commit
requests==2.28.1 # via sphinx
rich==12.6.0 # via gray
six==1.16.0 # via tox
snowballstemmer==2.2.0 # via sphinx
sphinx==5.3.0 # via -r dev-requirements.in
sphinxcontrib-applehelp==1.0.2 # via sphinx
@ -72,14 +74,14 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.5 # via sphinx
tokenize-rt==5.0.0 # via add-trailing-comma, pyupgrade
toml==0.10.2 # via autoflake, pre-commit
tomli==2.0.1 # via black, build, coverage, mypy, pep517, pytest, tox
tox==3.27.1 # via -r dev-requirements.in
tomli==2.0.1 # via black, build, coverage, mypy, pep517, pyproject-api, pytest, tox
tox==4.0.0 # via -r dev-requirements.in
typing-extensions==4.4.0 # via black, libcst, mypy, typing-inspect
typing-inspect==0.8.0 # via libcst
unify==0.5 # via gray
untokenize==0.1.1 # via unify
urllib3==1.26.13 # via requests
virtualenv==20.17.0 # via pre-commit, tox
virtualenv==20.17.1 # via pre-commit, tox
wheel==0.38.4 # via pip-tools
zipp==3.11.0 # via importlib-metadata, importlib-resources

View File

@ -25,4 +25,5 @@ wrapt
kiss3
attrs==22.1.0
# for mobile checking
device-detector
user-agents
pyopenssl

View File

@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --annotation-style=line --resolver=backtracking requirements.in
#
@ -11,11 +11,12 @@ beautifulsoup4==4.11.1 # via -r requirements.in
bidict==0.22.0 # via python-socketio
bitarray==2.6.0 # via ax253, kiss3
certifi==2022.9.24 # via requests
cffi==1.15.1 # via cryptography
charset-normalizer==2.1.1 # via requests
click==8.1.3 # via -r requirements.in, click-completion, flask
click-completion==0.5.2 # via -r requirements.in
commonmark==0.9.1 # via rich
device-detector==5.0.1 # via -r requirements.in
cryptography==38.0.4 # via pyopenssl
dnspython==2.2.1 # via eventlet
eventlet==0.33.2 # via -r requirements.in
flask==2.1.2 # via -r requirements.in, flask-classful, flask-httpauth, flask-socketio
@ -32,14 +33,15 @@ kiss3==8.0.0 # via -r requirements.in
markupsafe==2.1.1 # via jinja2
pbr==5.11.0 # via -r requirements.in
pluggy==1.0.0 # via -r requirements.in
pycparser==2.21 # via cffi
pygments==2.13.0 # via rich
pyopenssl==22.1.0 # via -r requirements.in
pyserial==3.5 # via pyserial-asyncio
pyserial-asyncio==0.6 # via kiss3
python-engineio==4.3.4 # via python-socketio
python-socketio==5.7.2 # via flask-socketio
pytz==2022.6 # via -r requirements.in
pyyaml==6.0 # via -r requirements.in, device-detector
regex==2022.10.31 # via device-detector
pyyaml==6.0 # via -r requirements.in
requests==2.28.1 # via -r requirements.in, update-checker
rich==12.6.0 # via -r requirements.in
shellingham==1.5.0 # via click-completion
@ -47,8 +49,10 @@ six==1.16.0 # via -r requirements.in, click-completion, eventlet,
soupsieve==2.3.2.post1 # via beautifulsoup4
tabulate==0.9.0 # via -r requirements.in
thesmuggler==1.0.1 # via -r requirements.in
ua-parser==0.16.1 # via user-agents
update-checker==0.18.0 # via -r requirements.in
urllib3==1.26.13 # via requests
user-agents==2.2.0 # via -r requirements.in
werkzeug==2.1.2 # via -r requirements.in, flask
wrapt==1.14.1 # via -r requirements.in
zipp==3.11.0 # via importlib-metadata