Skip to content

Commit

Permalink
fixed readme syntax, geeeeezz
Browse files Browse the repository at this point in the history
  • Loading branch information
ampledata committed Aug 30, 2022
1 parent 8d6b11f commit b3abab3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
13 changes: 8 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Garmin inReach to Cursor on Target Gateway
.. image:: https://raw.githubusercontent.com/ampledata/inrcot/main/docs/az-ccso-sar.jpg
:alt: Screenshot of INRCOT being used on a Search & Rescue mission in Arizona.
:target: https://raw.githubusercontent.com/ampledata/inrcot/main/docs/az-ccso-sar.jpg

* Pictured: Screenshot of INRCOT being used on a Search & Rescue mission in Arizona.

The inReach to Cursor on Target Gateway (INRCOT) transforms Garmin inReach
Expand Down Expand Up @@ -34,7 +35,7 @@ Use Cases
=========

There are numerous applications for satellite based position location information,
including::
including:

1. Blue Force Tracking
2. Search & Rescue (SAR)
Expand Down Expand Up @@ -115,11 +116,13 @@ Configuration parameters can be specified either via environment variables or in
a INI-stile configuration file. You must create a configuration file, see
`example-config.ini` in the source respository.

Parameters::
Parameters:

* **DEFAULT_POLL_INTERVAL**: How many seconds between checking for new messages at the Spot API? Default: 120 (seconds).
* **DEFAULT_COT_STALE**: How many seconds until CoT is stale? Default: 600 (seconds)
* **DEFAULT_COT_TYPE**: "a-n-G-E-V-C" # CoT Event Type / 2525 type / SIDC-like. Default: neutral ground
* **DEFAULT_COT_TYPE**: CoT Event Type / 2525 type / SIDC-like. Default: neutral ground

TLS & other configuration parameters available via `PyTAK <https://github.com/ampledata/pytak#configuration-parameters>`_.


Example Configurations
Expand Down Expand Up @@ -149,7 +152,7 @@ Multiple feeds can be added by creating multiple `inrcot_feed` sections::
Individual feeds CoT output can be customized as well::

[inrcot]
COT_URL = tcp:takserver.example.com:8088
COT_URL = tcp://takserver.example.com:8088
POLL_INTERVAL = 120

[inrcot_feed_zzz]
Expand All @@ -162,7 +165,7 @@ Individual feeds CoT output can be customized as well::
Protected feeds are also supported::

[inrcot]
COT_URL = tcp:takserver.example.com:8088
COT_URL = tcp://takserver.example.com:8088
POLL_INTERVAL = 120

[inrcot_feed_ppp]
Expand Down
26 changes: 12 additions & 14 deletions inrcot/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ def _create_feeds(self, config: dict = None) -> None:
feed_conf = {
"feed_url": config[feed].get("FEED_URL"),
"cot_stale": config[feed].get(
"COT_STALE", inrcot.DEFAULT_COT_STALE),
"cot_type": config[feed].get(
"COT_TYPE", inrcot.DEFAULT_COT_TYPE),
"COT_STALE", inrcot.DEFAULT_COT_STALE
),
"cot_type": config[feed].get("COT_TYPE", inrcot.DEFAULT_COT_TYPE),
"cot_icon": config[feed].get("COT_ICON"),
"cot_name": config[feed].get("COT_NAME"),
}

# Support "private" MapShare feeds:
if config[feed].get("FEED_PASSWORD") and \
config[feed].get("FEED_USERNAME"):
if config[feed].get("FEED_PASSWORD") and config[feed].get(
"FEED_USERNAME"
):
feed_conf["feed_auth"] = aiohttp.BasicAuth(
config[feed].get("FEED_USERNAME"),
config[feed].get("FEED_PASSWORD")
config[feed].get("FEED_PASSWORD"),
)

self.inreach_feeds.append(feed_conf)
Expand All @@ -80,19 +81,15 @@ async def get_inreach_feeds(self):
async with aiohttp.ClientSession() as session:
try:
response = await session.request(
method="GET",
auth=feed_auth,
url=feed_conf.get("feed_url")
method="GET", auth=feed_auth, url=feed_conf.get("feed_url")
)
except Exception as exc: # NOQA pylint: disable=broad-except
self._logger.error(
"Exception raised while polling inReach API.")
self._logger.error("Exception raised while polling inReach API.")
self._logger.exception(exc)
return

if response.status == 200:
await self.handle_data(await response.content.read(),
feed_conf)
await self.handle_data(await response.content.read(), feed_conf)
else:
self._logger.error("No valid response from inReach API.")

Expand All @@ -101,7 +98,8 @@ async def run(self) -> None:
self._logger.info("Run: %s", self.__class__)

poll_interval: str = self.config.get(
"POLL_INTERVAL", inrcot.DEFAULT_POLL_INTERVAL)
"POLL_INTERVAL", inrcot.DEFAULT_POLL_INTERVAL
)

while 1:
await self.get_inreach_feeds()
Expand Down
5 changes: 4 additions & 1 deletion inrcot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
from asyncio import get_event_loop as get_running_loop


async def main(app_name: str, config: SectionProxy, original_config: ConfigParser) -> None:
async def main(
app_name: str, config: SectionProxy, original_config: ConfigParser
) -> None:
"""
Abstract implementation of an async main function.
Expand Down Expand Up @@ -104,6 +106,7 @@ def cli(app_name: str = "inrcot") -> None:
debug = config.getboolean("DEBUG")
if debug:
import pprint # pylint: disable=import-outside-toplevel

# FIXME: This doesn't work with weird bash escape stuff.
print("Showing Config: %s", config_file)
print("=" * 10)
Expand Down
12 changes: 6 additions & 6 deletions inrcot/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_tasks(
def split_feed(content: str) -> list:
"""Splits an inReach MapShare KML feed by 'Folder'"""
tree = ET.parse(io.BytesIO(content))
document = tree.find('{http://www.opengis.net/kml/2.2}Document')
document = tree.find("{http://www.opengis.net/kml/2.2}Document")
folder = document.findall("{http://www.opengis.net/kml/2.2}Folder")
return folder

Expand All @@ -71,8 +71,7 @@ def inreach_to_cot_xml(feed: str, feed_conf: dict = None) -> Union[ET.Element, N

placemarks = feed.find("{http://www.opengis.net/kml/2.2}Placemark")
_point = placemarks.find("{http://www.opengis.net/kml/2.2}Point")
coordinates = _point.find(
"{http://www.opengis.net/kml/2.2}coordinates").text
coordinates = _point.find("{http://www.opengis.net/kml/2.2}coordinates").text
_name = placemarks.find("{http://www.opengis.net/kml/2.2}name").text

ts = placemarks.find("{http://www.opengis.net/kml/2.2}TimeStamp")
Expand All @@ -87,9 +86,10 @@ def inreach_to_cot_xml(feed: str, feed_conf: dict = None) -> Union[ET.Element, N
# We want to use localtime + stale instead of lastUpdate time + stale
# This means a device could go offline and we might not know it?
_cot_stale = feed_conf.get("cot_stale", inrcot.DEFAULT_COT_STALE)
cot_stale = (datetime.datetime.now(datetime.timezone.utc) +
datetime.timedelta(
seconds=int(_cot_stale))).strftime(pytak.ISO_8601_UTC)
cot_stale = (
datetime.datetime.now(datetime.timezone.utc)
+ datetime.timedelta(seconds=int(_cot_stale))
).strftime(pytak.ISO_8601_UTC)

cot_type = feed_conf.get("cot_type", inrcot.DEFAULT_COT_TYPE)

Expand Down
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ def publish():
long_description_content_type="text/x-rst",
zip_safe=False,
include_package_data=True,
install_requires=[
"pytak >= 5.0.0",
"aiohttp"
],
install_requires=["pytak >= 5.0.0", "aiohttp"],
classifiers=[
"Programming Language :: Python",
"License :: OSI Approved :: Apache Software License"
],
keywords=[
"Satellite", "Cursor on Target", "ATAK", "TAK", "CoT"
"License :: OSI Approved :: Apache Software License",
],
keywords=["Satellite", "Cursor on Target", "ATAK", "TAK", "CoT"],
)

0 comments on commit b3abab3

Please sign in to comment.