Skip to content

Commit

Permalink
Issue #517 - TCP input/output support
Browse files Browse the repository at this point in the history
	- Adds a TCP client and server option to input streams
	- Adds option to use 0.0.0.0 for server binding
	- Adds TCP to output clients and the ability to send to a remote host
	- Adds factory methods to determine the correct stream to instantiate based on config
	- Updates docunmentation with new input/output specifications
	- Adds client specific tests
	- Adds additional stream tests
	- Repo wide formatting from bringing in pre-commit changes
	- Temporarily disables python 3.7 tests
  • Loading branch information
cjjacks committed Jul 26, 2024
1 parent 70d6ed4 commit e455afe
Show file tree
Hide file tree
Showing 88 changed files with 2,696 additions and 1,983 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
rev: v2.6.0
hooks:
- id: reorder-python-imports
files: ^src/|test/
files: ^ait/|tests/

- repo: local
hooks:
Expand All @@ -27,7 +27,7 @@ repos:
- id: black
name: black
entry: black
files: ^src/|test/
files: ^ait/|tests/
language: system
types: [python]

Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ docstring-min-length=-1
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=80
max-line-length=120

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
Expand Down
7 changes: 5 additions & 2 deletions ait/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

import sys

from ait.core import cfg # noqa: F401
from ait.core import log

# cfg isn't used but we want the AIT-level config attribute created
from ait.core import cfg, log # noqa


def deprecated(message):
Expand Down Expand Up @@ -45,3 +46,5 @@ def deprecated_func(*args, **kwargs):

sys.modules["ait"].SERVER_DEFAULT_XSUB_URL = "tcp://*:5559" # type: ignore[attr-defined]
sys.modules["ait"].SERVER_DEFAULT_XPUB_URL = "tcp://*:5560" # type: ignore[attr-defined]

from .constants import * # noqa
9 changes: 6 additions & 3 deletions ait/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ def __str__(self):

@property
def msg(self):
s = 'FalseWaitError: "False" boolean passed as argument to wait. Ensure wait ' \
s = (
'FalseWaitError: "False" boolean passed as argument to wait. Ensure wait '
'condition args are surrounded by lambda or " "'
)

if self._msg:
s += ": " + self._msg
Expand All @@ -110,7 +112,6 @@ class CmdAPI:
"""

def __init__(self, udp_dest=None, cmddict=None, verbose=False, cmdtopic=None):

if cmddict is None:
cmddict = cmd.getDefaultCmdDict()

Expand Down Expand Up @@ -847,7 +848,9 @@ def _send_msg_box_request(self, data):
log.error("User prompt request failed due to too many redirects")
ret = None
except requests.exceptions.Timeout:
raise APITimeoutError(timeout=conn_timeout, msg="User confirm prompt timed out")
raise APITimeoutError(
timeout=conn_timeout, msg="User confirm prompt timed out"
)
except KeyError:
log.error("User prompt request received malformed response")
ret = None
Expand Down
6 changes: 2 additions & 4 deletions ait/core/bin/ait_bsc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,18 +12,17 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Usage: ait-bsc
Start the ait BSC for capturing network traffic into PCAP files
and the manager server for RESTful manipulation of active loggers.
"""

import argparse
import os
import threading

import yaml
import argparse

import ait
from ait.core import bsc
Expand Down
8 changes: 2 additions & 6 deletions ait/core/bin/ait_bsc_create_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Usage:
ait-bsc-create-handler [options] <name> <loc> <port> <conn_type>
Expand All @@ -35,8 +33,8 @@
include handler metadata values as well as strftime
format characters [default: %Y-%m-%d-%H-%M-%S-{name}.pcap]
"""

import argparse

import requests


Expand All @@ -63,9 +61,7 @@ def main():
default="day",
)
parser.add_argument("--rotate-log-delta", type=int, default=1)
parser.add_argument(
"--file-name-pattern", default="%Y-%m-%d-%H-%M-%S-{name}.pcap"
)
parser.add_argument("--file-name-pattern", default="%Y-%m-%d-%H-%M-%S-{name}.pcap")

# Get command line arguments
args = vars(parser.parse_args())
Expand Down
4 changes: 1 addition & 3 deletions ait/core/bin/ait_bsc_stop_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Usage:
ait-bsc-stop-handler [options] <name>
Expand All @@ -23,9 +21,9 @@
--service-port=<port> The port for the BSC REST service connection
[default: 8080]
"""
import argparse

import requests
import argparse


def main():
Expand Down
2 changes: 1 addition & 1 deletion ait/core/bin/ait_ccsds_send_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

import socket
import struct
import time

from ait.core import log

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down
4 changes: 2 additions & 2 deletions ait/core/bin/ait_cmd_hist.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

import argparse

from ait.core import log, pcap
from ait.core import log
from ait.core import pcap


"""Query all commands from a Command History PCAP"""
Expand Down
8 changes: 3 additions & 5 deletions ait/core/bin/ait_cmd_send.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

#
#
# Sends the given command and its arguments to the ISS simulator via
Expand All @@ -23,7 +21,6 @@
# $ ait-cmd-send OCO3_CMD_START_SEQUENCE_NOW 1
#
#

"""
usage: ait-cmd-send [options] command [arguments]
Expand All @@ -40,12 +37,13 @@
$ ait-cmd-send OCO3_CMD_START_SEQUENCE_NOW 1
"""

import argparse
from collections import OrderedDict

import ait
from ait.core import api, log, util
from ait.core import api
from ait.core import log
from ait.core import util


def main():
Expand Down
12 changes: 5 additions & 7 deletions ait/core/bin/ait_create_dirs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Usage:
ait-create-dirs [options]
Expand Down Expand Up @@ -114,15 +112,15 @@
"""

import os
import errno
import traceback
import argparse
import errno
import os
import time
import traceback

import ait
from ait.core import dmc, log
from ait.core import dmc
from ait.core import log


def create_dir_struct(paths, verbose=True):
Expand Down
8 changes: 3 additions & 5 deletions ait/core/bin/ait_dict_writer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Usage:
ait-dict-writer [options] (--tlm | --cmd)
Expand All @@ -39,11 +37,11 @@
Copyright 2016 California Institute of Technology. ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
"""

import sys
import argparse
import sys

from ait.core import log, tlm
from ait.core import log
from ait.core import tlm


def main():
Expand Down
2 changes: 0 additions & 2 deletions ait/core/bin/ait_limits_find_dn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
ait-limits-find-dn
Expand All @@ -39,7 +38,6 @@
- TABLE_FOO
- TABLE_BAR
"""

from ait.core import limits
from ait.core import log
from ait.core import tlm
Expand Down
1 change: 0 additions & 1 deletion ait/core/bin/ait_mps_seq_convert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

import argparse
import datetime as dt
import os.path
Expand Down
8 changes: 4 additions & 4 deletions ait/core/bin/ait_pcap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,16 +12,17 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
Provides a command line script for running pcap library functions.
"""

import argparse
import datetime
import os

from ait.core import dmc, log, pcap, util
from ait.core import dmc
from ait.core import log
from ait.core import pcap
from ait.core import util


def main():
Expand Down
8 changes: 2 additions & 6 deletions ait/core/bin/ait_pcap_segment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,8 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.


"""
Segments one or more pcap files into multiple pcap files, according to
a threshold number of bytes, packets, and/or seconds. New segment
Expand All @@ -37,11 +34,10 @@
And a new file will be started when a packet is written with a
timestamp that exceeds 2017-11-23 19:59:59.
"""


import argparse

from ait.core import log, pcap
from ait.core import log
from ait.core import pcap


def main():
Expand Down
8 changes: 3 additions & 5 deletions ait/core/bin/ait_seq_decode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python

# Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT)
# Bespoke Link to Instruments and Small Satellites (BLISS)
#
Expand All @@ -13,7 +12,6 @@
# laws and regulations. User has the responsibility to obtain export licenses,
# or other export authority as may be required before exporting such
# information to foreign countries or providing access to foreign persons.

"""
usage: ait-seq-decode ait_seq_SSS_desc_NNN.bin
Expand All @@ -24,11 +22,11 @@
$ ait-seq-decode seq/ait_seq_gps_reset_001.bin
"""

import os
import argparse
import os

from ait.core import log, seq
from ait.core import log
from ait.core import seq


def main():
Expand Down
Loading

0 comments on commit e455afe

Please sign in to comment.