mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-26 09:58:39 -05:00
Added aprsd version checking
This patch adds usage of update_checker to check to make sure the version of APRSD being launched is the latest version. Also added a call to upate_checker as part of the KeepAlive thread. It will call update_check every hour. If there is no aprsd connectivitity, the update check will silently fail.
This commit is contained in:
parent
2f7fa0c3d5
commit
17302aa76d
@ -199,6 +199,43 @@ def setup_logging(config, loglevel, quiet):
|
|||||||
imap_logger.addHandler(sh)
|
imap_logger.addHandler(sh)
|
||||||
|
|
||||||
|
|
||||||
|
@main.command()
|
||||||
|
@click.option(
|
||||||
|
"--loglevel",
|
||||||
|
default="INFO",
|
||||||
|
show_default=True,
|
||||||
|
type=click.Choice(
|
||||||
|
["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"],
|
||||||
|
case_sensitive=False,
|
||||||
|
),
|
||||||
|
show_choices=True,
|
||||||
|
help="The log level to use for aprsd.log",
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
"-c",
|
||||||
|
"--config",
|
||||||
|
"config_file",
|
||||||
|
show_default=True,
|
||||||
|
default=utils.DEFAULT_CONFIG_FILE,
|
||||||
|
help="The aprsd config file to use for options.",
|
||||||
|
)
|
||||||
|
def check_version(loglevel, config_file):
|
||||||
|
config = utils.parse_config(config_file)
|
||||||
|
|
||||||
|
# Force setting the config to the modules that need it
|
||||||
|
# TODO(Walt): convert these modules to classes that can
|
||||||
|
# Accept the config as a constructor param, instead of this
|
||||||
|
# hacky global setting
|
||||||
|
email.CONFIG = config
|
||||||
|
|
||||||
|
setup_logging(config, loglevel, False)
|
||||||
|
level, msg = utils._check_version()
|
||||||
|
if level:
|
||||||
|
LOG.warning(msg)
|
||||||
|
else:
|
||||||
|
LOG.info(msg)
|
||||||
|
|
||||||
|
|
||||||
@main.command()
|
@main.command()
|
||||||
def sample_config():
|
def sample_config():
|
||||||
"""This dumps the config to stdout."""
|
"""This dumps the config to stdout."""
|
||||||
@ -417,6 +454,12 @@ def server(
|
|||||||
email.CONFIG = config
|
email.CONFIG = config
|
||||||
|
|
||||||
setup_logging(config, loglevel, quiet)
|
setup_logging(config, loglevel, quiet)
|
||||||
|
level, msg = utils._check_version()
|
||||||
|
if level:
|
||||||
|
LOG.warning(msg)
|
||||||
|
else:
|
||||||
|
LOG.info(msg)
|
||||||
|
|
||||||
if config["aprsd"].get("trace", False):
|
if config["aprsd"].get("trace", False):
|
||||||
trace.setup_tracing(["method", "api"])
|
trace.setup_tracing(["method", "api"])
|
||||||
LOG.info("APRSD Started version: {}".format(aprsd.__version__))
|
LOG.info("APRSD Started version: {}".format(aprsd.__version__))
|
||||||
|
@ -67,10 +67,11 @@ class APRSDThread(threading.Thread, metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
class KeepAliveThread(APRSDThread):
|
class KeepAliveThread(APRSDThread):
|
||||||
cntr = 0
|
cntr = 0
|
||||||
|
checker_time = datetime.datetime.now()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("KeepAlive")
|
|
||||||
tracemalloc.start()
|
tracemalloc.start()
|
||||||
|
super().__init__("KeepAlive")
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
if self.cntr % 6 == 0:
|
if self.cntr % 6 == 0:
|
||||||
@ -102,6 +103,13 @@ class KeepAliveThread(APRSDThread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
LOG.debug(keepalive)
|
LOG.debug(keepalive)
|
||||||
|
# Check version every hour
|
||||||
|
delta = now - self.checker_time
|
||||||
|
if delta > datetime.timedelta(hours=1):
|
||||||
|
self.checker_time = now
|
||||||
|
level, msg = utils._check_version()
|
||||||
|
if level:
|
||||||
|
LOG.warning(msg)
|
||||||
self.cntr += 1
|
self.cntr += 1
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
return True
|
return True
|
||||||
|
@ -8,8 +8,10 @@ from pathlib import Path
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
import aprsd
|
||||||
from aprsd import plugin
|
from aprsd import plugin
|
||||||
import click
|
import click
|
||||||
|
import update_checker
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
LOG_LEVELS = {
|
LOG_LEVELS = {
|
||||||
@ -364,7 +366,7 @@ def parse_config(config_file):
|
|||||||
|
|
||||||
|
|
||||||
def human_size(bytes, units=None):
|
def human_size(bytes, units=None):
|
||||||
""" Returns a human readable string representation of bytes """
|
"""Returns a human readable string representation of bytes"""
|
||||||
if not units:
|
if not units:
|
||||||
units = [" bytes", "KB", "MB", "GB", "TB", "PB", "EB"]
|
units = [" bytes", "KB", "MB", "GB", "TB", "PB", "EB"]
|
||||||
return str(bytes) + units[0] if bytes < 1024 else human_size(bytes >> 10, units[1:])
|
return str(bytes) + units[0] if bytes < 1024 else human_size(bytes >> 10, units[1:])
|
||||||
@ -375,3 +377,20 @@ def strfdelta(tdelta, fmt="{hours}:{minutes}:{seconds}"):
|
|||||||
d["hours"], rem = divmod(tdelta.seconds, 3600)
|
d["hours"], rem = divmod(tdelta.seconds, 3600)
|
||||||
d["minutes"], d["seconds"] = divmod(rem, 60)
|
d["minutes"], d["seconds"] = divmod(rem, 60)
|
||||||
return fmt.format(**d)
|
return fmt.format(**d)
|
||||||
|
|
||||||
|
|
||||||
|
def _check_version():
|
||||||
|
# check for a newer version
|
||||||
|
try:
|
||||||
|
check = update_checker.UpdateChecker()
|
||||||
|
result = check.check("aprsd", aprsd.__version__)
|
||||||
|
if result:
|
||||||
|
# Looks like there is an updated version.
|
||||||
|
return 1, result
|
||||||
|
else:
|
||||||
|
return 0, "APRSD is up to date"
|
||||||
|
except Exception:
|
||||||
|
# probably can't get in touch with pypi for some reason
|
||||||
|
# Lets put up an error and move on. We might not
|
||||||
|
# have internet in this aprsd deployment.
|
||||||
|
return 1, "Couldn't check for new version of APRSD"
|
||||||
|
@ -12,15 +12,15 @@ appdirs==1.4.4
|
|||||||
# virtualenv
|
# virtualenv
|
||||||
attrs==20.3.0
|
attrs==20.3.0
|
||||||
# via pytest
|
# via pytest
|
||||||
babel==2.9.0
|
babel==2.9.1
|
||||||
# via sphinx
|
# via sphinx
|
||||||
black==20.8b1
|
black==21.4b2
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
bleach==3.3.0
|
bleach==3.3.0
|
||||||
# via readme-renderer
|
# via readme-renderer
|
||||||
certifi==2020.12.5
|
certifi==2020.12.5
|
||||||
# via requests
|
# via requests
|
||||||
cffi==1.14.4
|
cffi==1.14.5
|
||||||
# via cryptography
|
# via cryptography
|
||||||
cfgv==3.2.0
|
cfgv==3.2.0
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
@ -32,9 +32,9 @@ click==7.1.2
|
|||||||
# pip-tools
|
# pip-tools
|
||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
# via twine
|
# via twine
|
||||||
coverage==5.3.1
|
coverage==5.5
|
||||||
# via pytest-cov
|
# via pytest-cov
|
||||||
cryptography==3.3.2
|
cryptography==3.4.7
|
||||||
# via secretstorage
|
# via secretstorage
|
||||||
distlib==0.3.1
|
distlib==0.3.1
|
||||||
# via virtualenv
|
# via virtualenv
|
||||||
@ -48,19 +48,23 @@ filelock==3.0.12
|
|||||||
# virtualenv
|
# virtualenv
|
||||||
flake8-polyfill==1.0.2
|
flake8-polyfill==1.0.2
|
||||||
# via pep8-naming
|
# via pep8-naming
|
||||||
flake8==3.8.4
|
flake8==3.9.1
|
||||||
# via
|
# via
|
||||||
# -r dev-requirements.in
|
# -r dev-requirements.in
|
||||||
# flake8-polyfill
|
# flake8-polyfill
|
||||||
identify==2.2.2
|
identify==2.2.4
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
idna==2.10
|
idna==2.10
|
||||||
# via requests
|
# via requests
|
||||||
imagesize==1.2.0
|
imagesize==1.2.0
|
||||||
# via sphinx
|
# via sphinx
|
||||||
|
importlib-metadata==4.0.1
|
||||||
|
# via
|
||||||
|
# keyring
|
||||||
|
# twine
|
||||||
iniconfig==1.1.1
|
iniconfig==1.1.1
|
||||||
# via pytest
|
# via pytest
|
||||||
isort==5.7.0
|
isort==5.8.0
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
jeepney==0.6.0
|
jeepney==0.6.0
|
||||||
# via
|
# via
|
||||||
@ -68,7 +72,7 @@ jeepney==0.6.0
|
|||||||
# secretstorage
|
# secretstorage
|
||||||
jinja2==2.11.3
|
jinja2==2.11.3
|
||||||
# via sphinx
|
# via sphinx
|
||||||
keyring==21.8.0
|
keyring==23.0.1
|
||||||
# via twine
|
# via twine
|
||||||
markupsafe==1.1.1
|
markupsafe==1.1.1
|
||||||
# via jinja2
|
# via jinja2
|
||||||
@ -78,11 +82,11 @@ mypy-extensions==0.4.3
|
|||||||
# via
|
# via
|
||||||
# black
|
# black
|
||||||
# mypy
|
# mypy
|
||||||
mypy==0.790
|
mypy==0.812
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
nodeenv==1.5.0
|
nodeenv==1.6.0
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
packaging==20.8
|
packaging==20.9
|
||||||
# via
|
# via
|
||||||
# bleach
|
# bleach
|
||||||
# pytest
|
# pytest
|
||||||
@ -94,45 +98,45 @@ pep517==0.10.0
|
|||||||
# via pip-tools
|
# via pip-tools
|
||||||
pep8-naming==0.11.1
|
pep8-naming==0.11.1
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
pip-tools==6.0.1
|
pip-tools==6.1.0
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
pkginfo==1.6.1
|
pkginfo==1.7.0
|
||||||
# via twine
|
# via twine
|
||||||
pluggy==0.13.1
|
pluggy==0.13.1
|
||||||
# via
|
# via
|
||||||
# pytest
|
# pytest
|
||||||
# tox
|
# tox
|
||||||
pre-commit==2.11.1
|
pre-commit==2.12.1
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
py==1.10.0
|
py==1.10.0
|
||||||
# via
|
# via
|
||||||
# pytest
|
# pytest
|
||||||
# tox
|
# tox
|
||||||
pycodestyle==2.6.0
|
pycodestyle==2.7.0
|
||||||
# via flake8
|
# via flake8
|
||||||
pycparser==2.20
|
pycparser==2.20
|
||||||
# via cffi
|
# via cffi
|
||||||
pyflakes==2.2.0
|
pyflakes==2.3.1
|
||||||
# via flake8
|
# via flake8
|
||||||
pygments==2.7.4
|
pygments==2.9.0
|
||||||
# via
|
# via
|
||||||
# readme-renderer
|
# readme-renderer
|
||||||
# sphinx
|
# sphinx
|
||||||
pyparsing==2.4.7
|
pyparsing==2.4.7
|
||||||
# via packaging
|
# via packaging
|
||||||
pytest-cov==2.10.1
|
pytest-cov==2.11.1
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
pytest==6.2.1
|
pytest==6.2.3
|
||||||
# via
|
# via
|
||||||
# -r dev-requirements.in
|
# -r dev-requirements.in
|
||||||
# pytest-cov
|
# pytest-cov
|
||||||
pytz==2020.5
|
pytz==2021.1
|
||||||
# via babel
|
# via babel
|
||||||
pyyaml==5.4.1
|
pyyaml==5.4.1
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
readme-renderer==28.0
|
readme-renderer==29.0
|
||||||
# via twine
|
# via twine
|
||||||
regex==2020.11.13
|
regex==2021.4.4
|
||||||
# via black
|
# via black
|
||||||
requests-toolbelt==0.9.1
|
requests-toolbelt==0.9.1
|
||||||
# via twine
|
# via twine
|
||||||
@ -143,18 +147,17 @@ requests==2.25.1
|
|||||||
# twine
|
# twine
|
||||||
rfc3986==1.4.0
|
rfc3986==1.4.0
|
||||||
# via twine
|
# via twine
|
||||||
secretstorage==3.3.0
|
secretstorage==3.3.1
|
||||||
# via keyring
|
# via keyring
|
||||||
six==1.15.0
|
six==1.15.0
|
||||||
# via
|
# via
|
||||||
# bleach
|
# bleach
|
||||||
# cryptography
|
|
||||||
# readme-renderer
|
# readme-renderer
|
||||||
# tox
|
# tox
|
||||||
# virtualenv
|
# virtualenv
|
||||||
snowballstemmer==2.0.0
|
snowballstemmer==2.1.0
|
||||||
# via sphinx
|
# via sphinx
|
||||||
sphinx==3.4.3
|
sphinx==3.5.4
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
sphinxcontrib-applehelp==1.0.2
|
sphinxcontrib-applehelp==1.0.2
|
||||||
# via sphinx
|
# via sphinx
|
||||||
@ -175,28 +178,26 @@ toml==0.10.2
|
|||||||
# pre-commit
|
# pre-commit
|
||||||
# pytest
|
# pytest
|
||||||
# tox
|
# tox
|
||||||
tox==3.21.0
|
tox==3.23.0
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
tqdm==4.55.1
|
tqdm==4.60.0
|
||||||
# via twine
|
# via twine
|
||||||
twine==3.3.0
|
twine==3.4.1
|
||||||
# via -r dev-requirements.in
|
# via -r dev-requirements.in
|
||||||
typed-ast==1.4.2
|
typed-ast==1.4.3
|
||||||
# via
|
# via mypy
|
||||||
# black
|
typing-extensions==3.10.0.0
|
||||||
# mypy
|
# via mypy
|
||||||
typing-extensions==3.7.4.3
|
|
||||||
# via
|
|
||||||
# black
|
|
||||||
# mypy
|
|
||||||
urllib3==1.26.4
|
urllib3==1.26.4
|
||||||
# via requests
|
# via requests
|
||||||
virtualenv==20.4.0
|
virtualenv==20.4.4
|
||||||
# via
|
# via
|
||||||
# pre-commit
|
# pre-commit
|
||||||
# tox
|
# tox
|
||||||
webencodings==0.5.1
|
webencodings==0.5.1
|
||||||
# via bleach
|
# via bleach
|
||||||
|
zipp==3.4.1
|
||||||
|
# via importlib-metadata
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
# The following packages are considered to be unsafe in a requirements file:
|
||||||
# pip
|
# pip
|
||||||
|
@ -9,9 +9,12 @@ opencage
|
|||||||
pluggy
|
pluggy
|
||||||
pbr
|
pbr
|
||||||
pyyaml
|
pyyaml
|
||||||
py3-validate-email
|
# Allowing a newer version can lead to a conflict with
|
||||||
|
# requests.
|
||||||
|
py3-validate-email==0.2.16
|
||||||
pytz
|
pytz
|
||||||
requests
|
requests
|
||||||
six
|
six
|
||||||
thesmuggler
|
thesmuggler
|
||||||
yfinance
|
yfinance
|
||||||
|
update_checker
|
||||||
|
@ -10,7 +10,7 @@ backoff==1.10.0
|
|||||||
# via opencage
|
# via opencage
|
||||||
certifi==2020.12.5
|
certifi==2020.12.5
|
||||||
# via requests
|
# via requests
|
||||||
cffi==1.14.4
|
cffi==1.14.5
|
||||||
# via cryptography
|
# via cryptography
|
||||||
chardet==4.0.0
|
chardet==4.0.0
|
||||||
# via requests
|
# via requests
|
||||||
@ -21,7 +21,7 @@ click==7.1.2
|
|||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# click-completion
|
# click-completion
|
||||||
# flask
|
# flask
|
||||||
cryptography==3.3.2
|
cryptography==3.4.7
|
||||||
# via pyopenssl
|
# via pyopenssl
|
||||||
dnspython==2.1.0
|
dnspython==2.1.0
|
||||||
# via py3-validate-email
|
# via py3-validate-email
|
||||||
@ -29,7 +29,7 @@ filelock==3.0.12
|
|||||||
# via py3-validate-email
|
# via py3-validate-email
|
||||||
flask-classful==0.14.2
|
flask-classful==0.14.2
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
flask-httpauth==4.2.0
|
flask-httpauth==4.3.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
flask==1.1.2
|
flask==1.1.2
|
||||||
# via
|
# via
|
||||||
@ -54,19 +54,19 @@ markupsafe==1.1.1
|
|||||||
# via jinja2
|
# via jinja2
|
||||||
multitasking==0.0.9
|
multitasking==0.0.9
|
||||||
# via yfinance
|
# via yfinance
|
||||||
numpy==1.20.1
|
numpy==1.20.2
|
||||||
# via
|
# via
|
||||||
# pandas
|
# pandas
|
||||||
# yfinance
|
# yfinance
|
||||||
opencage==1.2.2
|
opencage==1.2.2
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
pandas==1.2.2
|
pandas==1.2.4
|
||||||
# via yfinance
|
# via yfinance
|
||||||
pbr==5.5.1
|
pbr==5.6.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
pluggy==0.13.1
|
pluggy==0.13.1
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
py3-validate-email==0.2.12
|
py3-validate-email==0.2.16
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
pycparser==2.20
|
pycparser==2.20
|
||||||
# via cffi
|
# via cffi
|
||||||
@ -74,7 +74,7 @@ pyopenssl==20.0.1
|
|||||||
# via opencage
|
# via opencage
|
||||||
python-dateutil==2.8.1
|
python-dateutil==2.8.1
|
||||||
# via pandas
|
# via pandas
|
||||||
pytz==2020.5
|
pytz==2021.1
|
||||||
# via
|
# via
|
||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# pandas
|
# pandas
|
||||||
@ -84,23 +84,25 @@ requests==2.25.1
|
|||||||
# via
|
# via
|
||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# opencage
|
# opencage
|
||||||
|
# update-checker
|
||||||
# yfinance
|
# yfinance
|
||||||
shellingham==1.3.2
|
shellingham==1.4.0
|
||||||
# via click-completion
|
# via click-completion
|
||||||
six==1.15.0
|
six==1.15.0
|
||||||
# via
|
# via
|
||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# click-completion
|
# click-completion
|
||||||
# cryptography
|
|
||||||
# imapclient
|
# imapclient
|
||||||
# opencage
|
# opencage
|
||||||
# pyopenssl
|
# pyopenssl
|
||||||
# python-dateutil
|
# python-dateutil
|
||||||
thesmuggler==1.0.1
|
thesmuggler==1.0.1
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
|
update-checker==0.18.0
|
||||||
|
# via -r requirements.in
|
||||||
urllib3==1.26.4
|
urllib3==1.26.4
|
||||||
# via requests
|
# via requests
|
||||||
werkzeug==1.0.1
|
werkzeug==1.0.1
|
||||||
# via flask
|
# via flask
|
||||||
yfinance==0.1.55
|
yfinance==0.1.59
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
|
Loading…
Reference in New Issue
Block a user