Skip to content

Commit

Permalink
Happy Summer Solstice
Browse files Browse the repository at this point in the history
- Fixes #72: Add a config variable for users to set expected CN when using CA verification. Thanks @ahoenerBE
- Added configuration parameter: PYTAK_TLS_SERVER_EXPECTED_HOSTNAME
- Rewrote GitHub actions, moved most logic to shell script and Makefile.
- Renamed Debian package from python3-pytak to pytak.
- Standardized Makefile for all PyTAK based programs.
- Cleaned, simplified and expanded documentation.
- Created Makefile jobs for Debian packaging and PyTAK customization.
- Moved all media to media sub directory under docs/.
- Converted README.rst to README.md.
- Style & Linting of code.
- Refactored TLS client creation, abstracted many functions.
- Added TLS client cert and key checks and improved error messages.
  • Loading branch information
ampledata committed Jun 22, 2024
1 parent 5d8b25f commit f51658a
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 111 deletions.
40 changes: 13 additions & 27 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Debian package
name: Build Debian Package

on:
push:
Expand All @@ -10,38 +10,24 @@ env:

jobs:
build-artifact:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@master

- name: Install packaging dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y \
python3 python3-dev python3-pip python3-venv python3-all \
dh-python debhelper devscripts dput software-properties-common \
python3-distutils python3-setuptools python3-wheel python3-stdeb
- name: Build Debian/Apt sdist_dsc
run: |
rm -Rf deb_dist/*
python3 setup.py --command-packages=stdeb.command sdist_dsc
- name: Build Debian/Apt bdist_deb
run: |
export REPO_NAME=$(echo ${{ github.repository }} | awk -F"/" '{print $2}')
python3 setup.py --command-packages=stdeb.command bdist_deb
ls -al deb_dist/
cp deb_dist/python3-${REPO_NAME}_*_all.deb deb_dist/python3-${REPO_NAME}_latest_all.deb
- uses: actions/upload-artifact@master
- name: Install Debian Package Building Dependencies
run: sudo bash debian/install_pkg_build_deps.sh

- name: Create Debian Package
run: make clean package

- name: Upload Artifacts to GitHub
uses: actions/upload-artifact@master
with:
name: artifact-deb
path: |
deb_dist/*.deb
path: deb_dist/*.deb

- name: Create Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@master
env:
Expand All @@ -52,7 +38,7 @@ jobs:
draft: false
prerelease: false

- name: Upload Release Asset
- name: Upload Release Asset to GitHub
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## TAKProto 3.0.0

Happy Summer Solstice!

- Fixes #15: Time data from iTak not parsed.
- Fixes #12: Add CHANGELOG
- Fixes #19: Support timestamps without microseconds. Thanks @sei-jmattson
- Fixes #17/#18: Support mixed-mode rx. Thanks @sei-jmattson
- Fixes #16: Fix datetime parsing for newer TAK clients that don't include microseconds in the timestamp. Thanks @brian7704
- Rewrote GitHub actions, moved most logic to shell script and Makefile.
- Renamed Debian package from python3-takproto to takproto.
- Standardized Makefile for all PyTAK based programs.
- Cleaned, simplified and expanded documentation.
- Created Makefile jobs for Debian packaging and TAKProto customization.
- Moved all media to media sub directory under docs/.
- Converted README.rst to README.md.
- Style & Linting of code.

## TAKProto 2.1.1

- Fixes #12: Add Changelog.
Expand Down
58 changes: 37 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Makefile from https://github.com/snstac/pytak
# PyTAK Makefile
#
# Copyright Sensors & Signals LLC https://www.snstac.com
# Copyright Sensors & Signals LLC https://www.snstac.com/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author:: Greg Albrecht <[email protected]>
# Copyright:: Copyright Sensors & Signals LLC https://www.snstac.com
# License:: Apache License, Version 2.0
#

this_app = takproto
.DEFAULT_GOAL := all
REPO_NAME ?= $(shell echo $(wildcard */classes.py) | awk -F'/' '{print $$1}')
SHELL := /bin/bash
.DEFAULT_GOAL := editable
# postinst = $(wildcard debian/*.postinst.sh)
# service = $(wildcard debian/*.service)

all: editable
prepare:
mkdir -p build/

develop:
python3 setup.py develop
Expand All @@ -30,13 +30,13 @@ editable:
python3 -m pip install -e .

install_test_requirements:
python3 -m pip install -r requirements_test.txt
python3 -m pip install -r requirements_test.txt

install:
python3 setup.py install

uninstall:
python3 -m pip uninstall -y $(this_app)
python3 -m pip uninstall -y $(REPO_NAME)

reinstall: uninstall install

Expand All @@ -47,16 +47,16 @@ clean:
@rm -rf *.egg* build dist *.py[oc] */*.py[co] cover doctest_pypi.cfg \
nosetests.xml pylint.log output.xml flake8.log tests.log \
test-result.xml htmlcov fab.log .coverage __pycache__ \
*/__pycache__ .mypy_cache .pytest_cache
*/__pycache__ deb_dist .mypy_cache

pep8:
flake8 --max-line-length=88 --extend-ignore=E203,E231 --exit-zero $(this_app)/*.py
flake8 --max-line-length=88 --extend-ignore=E203 --exit-zero $(REPO_NAME)/*.py

flake8: pep8

lint:
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
--max-line-length=88 -r n $(this_app)/*.py || exit 0
--max-line-length=88 -r n $(REPO_NAME)/*.py || exit 0

pylint: lint

Expand All @@ -72,7 +72,7 @@ pytest:
test: editable install_test_requirements pytest

test_cov:
pytest --cov=$(this_app) --cov-report term-missing
pytest --cov=$(REPO_NAME) --cov-report term-missing

black:
black .
Expand All @@ -81,7 +81,23 @@ mkdocs:
pip install -r docs/requirements.txt
mkdocs serve

proto:
for p in src-protobuf/*.proto; do \
protoc -v -I=src-protobuf --python_out=takprotobuf/proto $$p; \
done
deb_dist:
python3 setup.py --command-packages=stdeb.command sdist_dsc

deb_custom:
cp debian/$(REPO_NAME).conf $(wildcard deb_dist/*/debian)/$(REPO_NAME).default
cp debian/$(REPO_NAME).postinst $(wildcard deb_dist/*/debian)/$(REPO_NAME).postinst
cp debian/$(REPO_NAME).service $(wildcard deb_dist/*/debian)/$(REPO_NAME).service

bdist_deb: deb_dist deb_custom
cd deb_dist/$(REPO_NAME)-*/ && dpkg-buildpackage -rfakeroot -uc -us

faux_latest:
cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/$(REPO_NAME)_latest_all.deb
cp deb_dist/$(REPO_NAME)_*-1_all.deb deb_dist/python3-$(REPO_NAME)_latest_all.deb

package: bdist_deb faux_latest

extract:
dpkg-deb -e $(wildcard deb_dist/*latest_all.deb) deb_dist/extract
dpkg-deb -x $(wildcard deb_dist/*latest_all.deb) deb_dist/extract
17 changes: 8 additions & 9 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
.. image:: https://takproto.readthedocs.io/en/latest/atak_screenshot_with_pytak_logo-x25.jpg
:alt: ATAK Screenshot with PyTAK Logo.
:target: https://github.com/snstac/takproto/blob/main/docs/atak_screenshot_with_pytak_logo.jpg
![ATAK Screenshot with PyTAK Logo.](https://takproto.readthedocs.io/en/latest/media/atak_screenshot_with_pytak_logo-x25.jpg)

TAKProto: TAK Protocol Python Module
************************************
# Send & Receive data from TAK with Python

TAKProto is a Python module for encoding & decoding TAK Protocol Payloads, for use with `TAK Products <https://tak.gov/>`_ including ATAK, WinTAK, iTAK, TAKX, TAK Tracker & TAK Server. TAKProto includes functions for converting TAK Protocol Protobuf messages to Python objects, and serializing CoT XML messages as Protobuf.
TAKProto is a Python module for encoding & decoding TAK Protocol Payloads, for use
with [TAK Products](https://www.tak.gov/) including ATAK, WinTAK, iTAK, TAKX, TAK
Tracker & TAK Server. TAKProto includes functions for converting TAK Protocol
Protobuf messages to Python objects, and serializing CoT XML messages as Protobuf.

`Documentation is available here. <https://takproto.rtfd.io/>`_
[Documentation is available here.](https://takproto.rtfd.io/)

License
=======
## Copyright & License
Copyright Sensors & Signals LLC https://www.snstac.com

Copyright 2020 Delta Bravo-15 <[email protected]>
Expand Down
10 changes: 10 additions & 0 deletions debian/install_pkg_build_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Installing Debian package build dependencies"

apt-get update -qq

apt-get install -y \
python3 python3-dev python3-pip python3-venv python3-all \
dh-python debhelper devscripts dput software-properties-common \
python3-distutils python3-setuptools python3-wheel python3-stdeb
Empty file added debian/pytak.conf
Empty file.
Empty file added debian/pytak.postinst
Empty file.
Empty file added debian/pytak.service
Empty file.
10 changes: 1 addition & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@

![ATAK Screenshot with PyTAK Logo.](atak_screenshot_with_pytak_logo-x25.jpg)

# TAKProto - Send & Receive Team Awareness Kit (TAK) packets with Python.

TAKProto is a Python module for encoding & decoding TAK Protocol Payloads, for use with [TAK Products](https://tak.gov) including ATAK, WinTAK, iTAK, TAKX, TAK Tracker & TAK Server. TAKProto includes functions for converting TAK Protocol Protobuf messages to Python objects, and serializing CoT XML messages as Protobuf.

[Documentation is available here.](https://takproto.rtfd.io)

{!README.md!}
9 changes: 5 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## Install on Debian, Ubuntu or Raspberry Pi

TAKProto is distributed as a Debian package (``.deb``). takproto should be compatible with most contemporary system-Python versions from Python 3.6 onward.
TAKProto is distributed as a Debian package (``.deb``). takproto should be compatible
with most contemporary system-Python versions from Python 3.6 onward.

To install takproto, download the takproto package and install using apt:

```sh linenums="1"
sudo apt update -y
wget https://github.com/snstac/takproto/releases/latest/download/python3-takproto_latest_all.deb
sudo apt install -f ./python3-takproto_latest_all.deb
sudo apt update -qq
wget https://github.com/snstac/takproto/releases/latest/download/takproto_latest_all.deb
sudo apt install -f ./takproto_latest_all.deb
```

## Install from Python Package Index (PyPI)
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion docs/tak_protocols.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ TAK Products configured for connecting to a TAK Server will send TAK Protocol Ve

The `takproto` module supports encoding and decoding all 3 formats of CoT messages.

![TAK Protocol Chart](takproto_chart.png)
![TAK Protocol Chart](media/takproto_chart.png)
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_name: TAKProto - Send & Receive Team Awareness Kit (TAK) packets with Python.
site_name: A Python package for the TAK Protocol.
site_url: https://takproto.rtfd.io/
repo_url: https://github.com/snstac/takproto/
site_description: A Python module to encode & decode Team Awareness Kit (TAK) Protocol-based Cursor on Target (CoT) messages.
Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Setup for the Python TAK Protocol Packet - Version 1 Module.
# setup.cfg from https://github.com/snstac/takproto
#
# Copyright Sensors & Signals LLC https://www.snstac.com
# Copyright 2020 Delta Bravo-15
Expand Down Expand Up @@ -31,9 +32,9 @@ project_urls =
CI: GitHub Actions = https://github.com/snstac/takproto/actions
GitHub: issues = https://github.com/snstac/takproto/issues
GitHub: repo = https://github.com/snstac/takproto
description = A Python module to encode & decode 'TAK Protocol Payload - Version 1' Protocol Buffer based Cursor on Target (CoT) messages.
long_description = file: README.rst
long_description_content_type = text/x-rst
description = TAKProto is a Python package for the TAK protocol.
long_description = file: README.md
long_description_content_type = text/markdown
maintainer = Greg Albrecht <[email protected]>
maintainer_email = [email protected]
license = MIT License
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# setup.py from https://github.com/snstac/takproto
#
# Copyright Sensors & Signals LLC https://www.snstac.com
# Copyright 2020 Delta Bravo-15
Expand All @@ -24,10 +25,7 @@
#


"""Setup for the Python TAK Protocol Packet - Version 1 Module.
:source: <https://github.com/snstac/takproto>
"""
"""Setup for the Python TAK Protocol Package."""

from setuptools import setup

Expand Down
22 changes: 5 additions & 17 deletions takproto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# __init__.py from https://github.com/snstac/takproto
#
# Copyright Sensors & Signals LLC https://www.snstac.com
#
Expand All @@ -22,17 +23,11 @@
# SOFTWARE.
#

"""TAKProto: Encode & Decode TAK Protocol Payloads using Python.
"""TAKProto: Encode & Decode TAK Protocol Payloads using Python."""

:author: Greg Albrecht <[email protected]>
:copyright: Copyright Sensors & Signals LLC https://www.snstac.com
:license: MIT License
:source: <https://github.com/snstac/takproto>
"""
__version__ = "3.0.0-beta1"

__version__ = "2.1.1"

# Python 3.6 test/build work-around:
# COMPAT Python 3.6 import work-around.
try:
from .functions import ( # NOQA
xml2proto,
Expand All @@ -44,12 +39,5 @@
from .constants import TAKProtoVer # NOQA
except ImportError as exc:
import warnings
warnings.warn(
"Unable to import required modules, IGNORING for Python 3.6 compat. Original Exception: "
)
warnings.warn(str(exc))

__author__ = "Greg Albrecht <[email protected]>"
__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com"
__license__ = "MIT License"
__source__ = "https://github.com/snstac/takproto"
warnings.warn(f"COMPAT Python 3.6. Ignoring Exception: {str(exc)}")
6 changes: 1 addition & 5 deletions takproto/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# constants.py from https://github.com/snstac/takproto
#
# Copyright Sensors & Signals LLC https://www.snstac.com
#
Expand All @@ -26,11 +27,6 @@

from enum import Enum

__author__ = "Greg Albrecht <[email protected]>"
__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com"
__license__ = "Apache License, Version 2.0"


DEFAULT_PROTO_HEADER = bytearray(b"\xbf")
DEFAULT_MESH_HEADER = bytearray(b"\xbf\x01\xbf")
DEFAULT_XML_HEADER = bytearray(b"<?xml")
Expand Down
Loading

0 comments on commit f51658a

Please sign in to comment.