diff --git a/ait/core/__init__.py b/ait/core/__init__.py index 54698e5e..647afcd7 100644 --- a/ait/core/__init__.py +++ b/ait/core/__init__.py @@ -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 +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): diff --git a/ait/core/api.py b/ait/core/api.py index 953f2683..3f636e72 100644 --- a/ait/core/api.py +++ b/ait/core/api.py @@ -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 @@ -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() @@ -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 diff --git a/ait/core/bin/ait_bsc_create_handler.py b/ait/core/bin/ait_bsc_create_handler.py index a1a401c0..31024613 100755 --- a/ait/core/bin/ait_bsc_create_handler.py +++ b/ait/core/bin/ait_bsc_create_handler.py @@ -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) # @@ -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] @@ -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 @@ -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()) diff --git a/ait/core/bin/ait_bsc_stop_handler.py b/ait/core/bin/ait_bsc_stop_handler.py index 37f3b63c..10538762 100755 --- a/ait/core/bin/ait_bsc_stop_handler.py +++ b/ait/core/bin/ait_bsc_stop_handler.py @@ -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) # @@ -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] @@ -23,9 +21,9 @@ --service-port= The port for the BSC REST service connection [default: 8080] """ +import argparse import requests -import argparse def main(): diff --git a/ait/core/bin/ait_ccsds_send_example.py b/ait/core/bin/ait_ccsds_send_example.py index 7defc4c0..1ed64f96 100755 --- a/ait/core/bin/ait_ccsds_send_example.py +++ b/ait/core/bin/ait_ccsds_send_example.py @@ -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) diff --git a/ait/core/bin/ait_cmd_hist.py b/ait/core/bin/ait_cmd_hist.py index a83000cf..28a69528 100755 --- a/ait/core/bin/ait_cmd_hist.py +++ b/ait/core/bin/ait_cmd_hist.py @@ -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""" diff --git a/ait/core/bin/ait_cmd_send.py b/ait/core/bin/ait_cmd_send.py index f99a76bc..4e43a32b 100755 --- a/ait/core/bin/ait_cmd_send.py +++ b/ait/core/bin/ait_cmd_send.py @@ -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) # @@ -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 @@ -23,7 +21,6 @@ # $ ait-cmd-send OCO3_CMD_START_SEQUENCE_NOW 1 # # - """ usage: ait-cmd-send [options] command [arguments] @@ -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(): diff --git a/ait/core/bin/ait_create_dirs.py b/ait/core/bin/ait_create_dirs.py index 1813c38d..e503b573 100755 --- a/ait/core/bin/ait_create_dirs.py +++ b/ait/core/bin/ait_create_dirs.py @@ -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) # @@ -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] @@ -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): diff --git a/ait/core/bin/ait_dict_writer.py b/ait/core/bin/ait_dict_writer.py index f15750be..309e0140 100755 --- a/ait/core/bin/ait_dict_writer.py +++ b/ait/core/bin/ait_dict_writer.py @@ -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) # @@ -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) @@ -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(): diff --git a/ait/core/bin/ait_limits_find_dn.py b/ait/core/bin/ait_limits_find_dn.py index 0e09eead..13cdf012 100644 --- a/ait/core/bin/ait_limits_find_dn.py +++ b/ait/core/bin/ait_limits_find_dn.py @@ -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 @@ -39,7 +38,6 @@ - TABLE_FOO - TABLE_BAR """ - from ait.core import limits from ait.core import log from ait.core import tlm diff --git a/ait/core/bin/ait_mps_seq_convert.py b/ait/core/bin/ait_mps_seq_convert.py index c13e799c..a30de670 100644 --- a/ait/core/bin/ait_mps_seq_convert.py +++ b/ait/core/bin/ait_mps_seq_convert.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - import argparse import datetime as dt import os.path diff --git a/ait/core/bin/ait_pcap.py b/ait/core/bin/ait_pcap.py index 88ce788a..b67b0663 100755 --- a/ait/core/bin/ait_pcap.py +++ b/ait/core/bin/ait_pcap.py @@ -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) # @@ -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(): diff --git a/ait/core/bin/ait_pcap_segment.py b/ait/core/bin/ait_pcap_segment.py index 3c45ed91..70f4df81 100644 --- a/ait/core/bin/ait_pcap_segment.py +++ b/ait/core/bin/ait_pcap_segment.py @@ -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) # @@ -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 @@ -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(): diff --git a/ait/core/bin/ait_seq_decode.py b/ait/core/bin/ait_seq_decode.py index 5aaf6e28..0e9456b4 100755 --- a/ait/core/bin/ait_seq_decode.py +++ b/ait/core/bin/ait_seq_decode.py @@ -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) # @@ -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 @@ -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(): diff --git a/ait/core/bin/ait_seq_encode.py b/ait/core/bin/ait_seq_encode.py index 3ef839a3..0c53c8c8 100755 --- a/ait/core/bin/ait_seq_encode.py +++ b/ait/core/bin/ait_seq_encode.py @@ -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) # @@ -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-encode mission_seq_SSS_desc_NNN.txt where: @@ -27,12 +25,12 @@ $ ait-seq-encode seq/ait_seq_gps_reset_001.txt """ - +import argparse import os import sys -import argparse -from ait.core import log, seq +from ait.core import log +from ait.core import seq def main(): diff --git a/ait/core/bin/ait_seq_print.py b/ait/core/bin/ait_seq_print.py index d52cf306..57c0a553 100755 --- a/ait/core/bin/ait_seq_print.py +++ b/ait/core/bin/ait_seq_print.py @@ -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) # @@ -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-print ait_seq_SSS_NNN_desc.bin @@ -24,11 +22,11 @@ $ ait-seq-print seq/ait_seq_gps_001_reset.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(): diff --git a/ait/core/bin/ait_seq_send.py b/ait/core/bin/ait_seq_send.py index 235d0208..07badecd 100755 --- a/ait/core/bin/ait_seq_send.py +++ b/ait/core/bin/ait_seq_send.py @@ -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) # @@ -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-send [options] filename.rts @@ -30,14 +28,15 @@ $ ait-seq-send test.rts """ - +import argparse import os import time -import argparse from collections import OrderedDict import ait.core -from ait.core import api, log, util +from ait.core import api +from ait.core import log +from ait.core import util def system(command): diff --git a/ait/core/bin/ait_server.py b/ait/core/bin/ait_server.py index e0a7cd96..df8e355a 100755 --- a/ait/core/bin/ait_server.py +++ b/ait/core/bin/ait_server.py @@ -1,12 +1,10 @@ #!/usr/bin/env python - """ Usage: ait-server Start the AIT telemetry server for managing telemety streams, command outputs, processing handlers, and plugins. """ - import argparse from ait.core.server import Server diff --git a/ait/core/bin/ait_table_decode.py b/ait/core/bin/ait_table_decode.py index cdc78403..8c52b7d5 100755 --- a/ait/core/bin/ait_table_decode.py +++ b/ait/core/bin/ait_table_decode.py @@ -13,14 +13,13 @@ # 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. - """Decode AIT FSW table binaries""" - import argparse import os.path import sys -from ait.core import log, table +from ait.core import log +from ait.core import table def main(): diff --git a/ait/core/bin/ait_tlm_csv.py b/ait/core/bin/ait_tlm_csv.py index eb2a3080..bf7497db 100755 --- a/ait/core/bin/ait_tlm_csv.py +++ b/ait/core/bin/ait_tlm_csv.py @@ -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) # @@ -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. - - """ Usage: ait-tlm-csv [options] @@ -40,15 +37,16 @@ $ ait-tlm-csv --packet 1553_HS_Packet --all --csv './ait-tlm-csv-output.csv' \ ./ait-tlm-csv-input.pcap """ - - import argparse import csv -import sys import os +import sys from datetime import datetime -from ait.core import log, tlm, pcap, dmc +from ait.core import dmc +from ait.core import log +from ait.core import pcap +from ait.core import tlm """Parses 1553 telemetry into CSV file.""" @@ -75,7 +73,9 @@ def main(): ) parser.add_argument( - "--packet", required=True, help="Packet name from telemetry dictionary specified in config file." + "--packet", + required=True, + help="Packet name from telemetry dictionary specified in config file.", ) parser.add_argument( diff --git a/ait/core/bin/ait_tlm_db_insert.py b/ait/core/bin/ait_tlm_db_insert.py index c5421254..b328b464 100755 --- a/ait/core/bin/ait_tlm_db_insert.py +++ b/ait/core/bin/ait_tlm_db_insert.py @@ -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) # @@ -13,18 +12,18 @@ # 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. - """ Inserts telemetry into a database from one or more PCAP files. """ - - import argparse import os import struct import ait -from ait.core import db, log, tlm, pcap +from ait.core import db +from ait.core import log +from ait.core import pcap +from ait.core import tlm def main(): @@ -98,7 +97,6 @@ def main(): log.info("Processing %s" % filename) with pcap.open(filename) as stream: for header, pkt_data in stream: - try: packet = tlm.Packet(defn, pkt_data) diff --git a/ait/core/bin/ait_tlm_send.py b/ait/core/bin/ait_tlm_send.py index fd557de7..5384bda2 100755 --- a/ait/core/bin/ait_tlm_send.py +++ b/ait/core/bin/ait_tlm_send.py @@ -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) # @@ -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-tlm-send [options] @@ -27,18 +25,16 @@ $ ait-tlm-send test/data/pcap/oco3fsw-iss1553-2015-04-22.pcap """ - - +import argparse import socket import time -import argparse -from ait.core import log, pcap +from ait.core import log +from ait.core import pcap def main(): try: - log.begin() parser = argparse.ArgumentParser( diff --git a/ait/core/bin/ait_tlm_simulate.py b/ait/core/bin/ait_tlm_simulate.py index 625ee93b..bf539ceb 100644 --- a/ait/core/bin/ait_tlm_simulate.py +++ b/ait/core/bin/ait_tlm_simulate.py @@ -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) # @@ -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-tlm-simulate [options] @@ -32,13 +30,12 @@ $ ait-tlm-simulate """ - - +import argparse import socket import time -import argparse -from ait.core import log, tlm +from ait.core import log +from ait.core import tlm def main(): diff --git a/ait/core/bin/ait_yaml_validate.py b/ait/core/bin/ait_yaml_validate.py index b7f98d66..e96b2016 100755 --- a/ait/core/bin/ait_yaml_validate.py +++ b/ait/core/bin/ait_yaml_validate.py @@ -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) # @@ -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-yaml-validate @@ -43,14 +41,17 @@ $ ait-yaml-validate --tlm --yaml /path/to/tlm.yaml $ ait-yaml-validate --yaml /path/to/yaml --schema /path/to/schema """ - - import argparse import os import sys import ait -from ait.core import cmd, evr, log, tlm, val, limits +from ait.core import cmd +from ait.core import evr +from ait.core import limits +from ait.core import log +from ait.core import tlm +from ait.core import val def validate(validator, yml, schema): diff --git a/ait/core/bsc.py b/ait/core/bsc.py index de24ee24..d1af1311 100644 --- a/ait/core/bsc.py +++ b/ait/core/bsc.py @@ -11,7 +11,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 Binary Stream Capturer @@ -19,20 +18,20 @@ along with the server definition for RESTful manipulation of running loggers. """ - import calendar import json import os import socket import time -from bottle import request, Bottle -import gevent import gevent.monkey import gevent.pool import gevent.socket +from bottle import Bottle +from bottle import request -from ait.core import pcap, log +from ait.core import log +from ait.core import pcap gevent.monkey.patch_all() diff --git a/ait/core/ccsds.py b/ait/core/ccsds.py index dedf4ddf..85550a2f 100644 --- a/ait/core/ccsds.py +++ b/ait/core/ccsds.py @@ -12,17 +12,15 @@ # 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. - - """ Consultative Committee for Space Data Systems (CCSDS) The ait.core.ccsds module provides CCSDS header definitions and datatypes. """ - - -from ait.core import json, tlm, util +from ait.core import json +from ait.core import tlm +from ait.core import util class CcsdsDefinition(json.SlotSerializer, object): diff --git a/ait/core/coord.py b/ait/core/coord.py index 8776c113..7ded6d6a 100644 --- a/ait/core/coord.py +++ b/ait/core/coord.py @@ -11,14 +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. - """ AIT Coordinate Functions The ait.core.coord module provides various coordinate manpulation and transformation functions. """ - import math from ait.core import dmc @@ -36,8 +34,8 @@ def __init__(self, a, b): """ self.a = a self.b = b - self.a2 = a ** 2 - self.b2 = b ** 2 + self.a2 = a**2 + self.b2 = b**2 self.f = (a - b) / a self.e2 = 1 - (self.b2 / self.a2) self.ep2 = (self.a2 - self.b2) / self.b2 diff --git a/ait/core/db.py b/ait/core/db.py index 0fcce1d7..d5a45590 100644 --- a/ait/core/db.py +++ b/ait/core/db.py @@ -11,24 +11,27 @@ # 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 Database The ait.db module provides a general database storage layer for commands and telemetry with several backends. """ - -from abc import ABCMeta, abstractmethod import datetime as dt import importlib import itertools import math import os.path - import sqlite3 +from abc import ABCMeta +from abc import abstractmethod import ait -from ait.core import cfg, cmd, dmc, evr, log, tlm +from ait.core import cfg +from ait.core import cmd +from ait.core import dmc +from ait.core import evr +from ait.core import log +from ait.core import tlm class AITDBResult: @@ -701,12 +704,16 @@ def insert(self, packet, time=None, **kwargs): if isinstance(time, dt.datetime): time = time.strftime(dmc.RFC3339_Format) - sql = f'INSERT INTO "{packet._defn.name}" (PKTDATA, time) VALUES (?, ?)' \ - if time \ + sql = ( + f'INSERT INTO "{packet._defn.name}" (PKTDATA, time) VALUES (?, ?)' + if time else f'INSERT INTO "{packet._defn.name}" (PKTDATA) VALUES (?)' - values = (sqlite3.Binary(packet._data), time) \ - if time \ + ) + values = ( + (sqlite3.Binary(packet._data), time) + if time else (sqlite3.Binary(packet._data)) + ) self._conn.execute(sql, values) self._conn.commit() diff --git a/ait/core/dmc.py b/ait/core/dmc.py index 9ebc06e1..b2d02c6c 100644 --- a/ait/core/dmc.py +++ b/ait/core/dmc.py @@ -11,7 +11,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 DeLorean Motor Company (DMC) The ait.dmc module provides utilities to represent, translate, and @@ -22,7 +21,6 @@ midnight. """ - import calendar import datetime import math @@ -175,8 +173,8 @@ def to_gmst(dt=None) -> float: t_ut1 = (jd - 2451545.0) / 36525.0 gmst = 67310.54841 + (876600 * 3600 + 8640184.812866) * t_ut1 - gmst += 0.093104 * t_ut1 ** 2 - gmst -= 6.2e-6 * t_ut1 ** 3 + gmst += 0.093104 * t_ut1**2 + gmst -= 6.2e-6 * t_ut1**3 # Convert from seconds to degrees, i.e. # 86400 seconds / 360 degrees = 240 seconds / degree @@ -370,7 +368,9 @@ def _update_leap_second_data(self): raise ValueError(msg) text = r.text.split("\n") - lines = [line for line in text if line.startswith("#@") or not line.startswith("#")] + lines = [ + line for line in text if line.startswith("#@") or not line.startswith("#") + ] data = {"valid": None, "leapseconds": []} data["valid"] = datetime.datetime(1900, 1, 1) + datetime.timedelta( diff --git a/ait/core/dtype.py b/ait/core/dtype.py index 59de89e7..5561c072 100644 --- a/ait/core/dtype.py +++ b/ait/core/dtype.py @@ -11,8 +11,8 @@ # 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. - from typing import Optional + from ait.core import util """AIT Primitive Data Types (PDT) @@ -175,7 +175,7 @@ def __init__(self, name): self._max = 2 ** (self.nbits - 1) self._min = -1 * (self.max - 1) elif not self.string: - self._max = 2 ** self.nbits - 1 + self._max = 2**self.nbits - 1 self._min = 0 def __eq__(self, other): @@ -811,7 +811,7 @@ def decode(self, bytes, raw=False): class CustomTypes: - '''Pseudo-ABC for users to inject custom types into AIT + """Pseudo-ABC for users to inject custom types into AIT CustomTypes is the vector through which users can inject custom types that they create into the toolkit. `dtype.get` is used throughout AIT to fetch @@ -822,14 +822,14 @@ class CustomTypes: Custom classes must inherit from PrimitiveType. For examples of "custom" types look at the implementation of the `ComplexTypeMap` classes. All of these build on top of PrimitiveType in some way. - ''' + """ def get(self, typename: str) -> Optional[PrimitiveType]: - '''Retrieve an instance of a type's class given its name + """Retrieve an instance of a type's class given its name Maps a class name to an instance of its respective class. Should return None if no match is found. - ''' + """ return None diff --git a/ait/core/gds.py b/ait/core/gds.py index 88695242..799c113c 100644 --- a/ait/core/gds.py +++ b/ait/core/gds.py @@ -11,16 +11,15 @@ # 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 Ground Data System The ait.core.gds module provides utility functions specific to GDS command-line tools. """ - -from typing import Optional, ByteString import zlib +from typing import ByteString +from typing import Optional from ait.core import log diff --git a/ait/core/geom.py b/ait/core/geom.py index 5c55c560..b86744ca 100755 --- a/ait/core/geom.py +++ b/ait/core/geom.py @@ -11,7 +11,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 2D/3D Geometry This module contains basic 2D and 3D geometry classes (Point, Line, diff --git a/ait/core/json.py b/ait/core/json.py index 8571f7ac..9d785a00 100644 --- a/ait/core/json.py +++ b/ait/core/json.py @@ -11,14 +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. - """ AIT Javascript Object Notation (JSON) The ait.core.json module provides JSON utilities and mixin classes for encoding and decoding between AIT data structures and JSON. """ - import collections.abc from typing import List diff --git a/ait/core/log.py b/ait/core/log.py index 7bea5a87..8d1b313d 100644 --- a/ait/core/log.py +++ b/ait/core/log.py @@ -11,24 +11,20 @@ # 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 Logging The ait.core.log module logs warnings, errors, and other information to standard output and via syslog. """ - -import sys -import socket import datetime -import time -from typing import Callable, Optional - -import logging import logging.handlers +import socket +import sys +import time +from typing import Callable +from typing import Optional -import ait import ait.core diff --git a/ait/core/notify.py b/ait/core/notify.py index 815bbb82..8d36d9ce 100644 --- a/ait/core/notify.py +++ b/ait/core/notify.py @@ -11,9 +11,8 @@ # 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. - -from email.mime.text import MIMEText import smtplib +from email.mime.text import MIMEText import ait from ait.core import log diff --git a/ait/core/pcap.py b/ait/core/pcap.py index 29d3ca67..be33ada3 100644 --- a/ait/core/pcap.py +++ b/ait/core/pcap.py @@ -11,17 +11,15 @@ # 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. - """ This module, pcap.py, is a library to read/write PCAP-formatted files with simple open, read, write, close functions. (PCAP - packet capture) """ - import builtins import calendar +import datetime import math import struct -import datetime from .dmc import get_timestamp_utc from ait.core import log @@ -53,6 +51,7 @@ class PCapGlobalHeader: https://wiki.wireshark.org/Development/LibpcapFileFormat """ + def __init__(self, stream=None): """Creates a new PCapGlobalHeader with default values. If a stream is given, the global header data is read from it. @@ -65,10 +64,10 @@ def __init__(self, stream=None): self.magic_number = 0xA1B2C3D4 # detects file format and byte ordering self.version_major = 2 self.version_minor = 4 - self.thiszone = 0 # GMT to local correction (0 == GMT) - self.sigfigs = 0 # accuracy of timestamps - self.snaplen = 65535 # max length of captured packets, in octets - self.network = 147 # data link type (147-162 are reserved for private use) + self.thiszone = 0 # GMT to local correction (0 == GMT) + self.sigfigs = 0 # accuracy of timestamps + self.snaplen = 65535 # max length of captured packets, in octets + self.network = 147 # data link type (147-162 are reserved for private use) self._data = self.pack() else: self.read(stream) @@ -79,10 +78,12 @@ def __len__(self): def __str__(self): """Returns this PCapGlobalHeader as a binary string.""" - return f'PCapGlobalHeader Class: \r\n format={self._format}, magic number={self.magic_number},'\ - f'major version={self.version_major}, minor version={self.version_minor}, \r\n' \ - f' time zone={self.thiszone}, timestamp accuracy={self.sigfigs}, max packet size={self.snaplen}, '\ - f'network={self.network}' + return ( + f"PCapGlobalHeader Class: \r\n format={self._format}, magic number={self.magic_number}," + f"major version={self.version_major}, minor version={self.version_minor}, \r\n" + f" time zone={self.thiszone}, timestamp accuracy={self.sigfigs}, max packet size={self.snaplen}, " + f"network={self.network}" + ) def pack(self): return struct.pack( @@ -161,9 +162,11 @@ def __len__(self): def __str__(self): """Returns this PCapPacketHeader as a binary string.""" - return f'PCapPacketHeader Class: \r\n format={self._format}, timestamp seconds={self.ts_sec},' \ - f'timestamp microseconds={self.ts_usec}.\r\n number of octets in file={self.incl_len}, ' \ - f'actual length of packet={self.orig_len}' + return ( + f"PCapPacketHeader Class: \r\n format={self._format}, timestamp seconds={self.ts_sec}," + f"timestamp microseconds={self.ts_usec}.\r\n number of octets in file={self.incl_len}, " + f"actual length of packet={self.orig_len}" + ) def pack(self): """Returns this PCapPacketHeader as a binary string.""" @@ -493,9 +496,7 @@ def query(starttime, endtime, output=None, *filenames): with open(filename, "r") as stream: for header, packet in stream: if packet is not None: - if ( - starttime <= header.timestamp <= endtime - ): + if starttime <= header.timestamp <= endtime: outfile.write(packet, header=header) diff --git a/ait/core/seq.py b/ait/core/seq.py index c3fe06db..0fc3593d 100644 --- a/ait/core/seq.py +++ b/ait/core/seq.py @@ -11,21 +11,20 @@ # 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 Sequences The ait.core.seq module provides sequences of commands. """ - from __future__ import absolute_import -import os import math +import os import struct import sys -from ait.core import cmd, util +from ait.core import cmd +from ait.core import util def set_bit(value, bit, bitval): @@ -202,7 +201,7 @@ def read_text(self, filename=None): in_body = False with open(filename, "rt") as stream: - for (lineno, line) in enumerate(stream.readlines()): + for lineno, line in enumerate(stream.readlines()): stripped = line.strip() if stripped == "": continue diff --git a/ait/core/server/__init__.py b/ait/core/server/__init__.py index 2e0bc635..6eee2fd4 100644 --- a/ait/core/server/__init__.py +++ b/ait/core/server/__init__.py @@ -1,6 +1,8 @@ from .broker import * # noqa -from .server import * # noqa -from .plugin import Plugin, PluginType, PluginConfig # noqa +from .config import ZmqConfig # noqa from .handler import Handler # noqa +from .plugin import Plugin # noqa +from .plugin import PluginConfig # noqa +from .plugin import PluginType # noqa from .process import * # noqa -from .config import ZmqConfig # noqa +from .server import * # noqa diff --git a/ait/core/server/broker.py b/ait/core/server/broker.py index 72c4e308..6908c7af 100644 --- a/ait/core/server/broker.py +++ b/ait/core/server/broker.py @@ -1,6 +1,5 @@ -import zmq.green as zmq -import gevent import gevent.monkey +import zmq.green as zmq gevent.monkey.patch_all() @@ -86,7 +85,8 @@ def _subscribe_all(self): log.warn( f"The outbound stream {output} does not " "exist so will not receive messages " - f"from {plugin}") + f"from {plugin}" + ) else: Broker.subscribe(subscriber, plugin.name) @@ -128,15 +128,18 @@ def _subscribe_cmdr(self): log.warn( f"Multiple output streams found with {cmd_sub_flag_field} " f"field enabled, {cmd_stream.name} was selected as the " - "default.") + "default." + ) # No stream yet, so just grab the first output stream if cmd_stream is None: cmd_stream = next((x for x in self.outbound_streams), None) if cmd_stream is not None: - log.warn("No output stream was designated as the command " - f"subscriber, {cmd_stream.name} was selected as " - "the default.") + log.warn( + "No output stream was designated as the command " + f"subscriber, {cmd_stream.name} was selected as " + "the default." + ) if cmd_stream is not None: Broker.subscribe(cmd_stream, self.command_topic) @@ -163,14 +166,14 @@ def subscribe_to_output(self, output_name, topic_name): # Search for output stream instance by name subscriber = next( - (x for x in self.outbound_streams if - x.name == output_name), None + (x for x in self.outbound_streams if x.name == output_name), None ) if subscriber is None: log.warn( f"The outbound stream {output_name} does not " "exist so will not receive messages " - f"from {topic_name}") + f"from {topic_name}" + ) return False else: # Finally, setup the output stream's subscription diff --git a/ait/core/server/client.py b/ait/core/server/client.py index 6c673caf..8cf8baef 100644 --- a/ait/core/server/client.py +++ b/ait/core/server/client.py @@ -1,7 +1,6 @@ -import gevent -import gevent.socket -import gevent.server as gs import gevent.monkey +import gevent.server as gs +import gevent.socket gevent.monkey.patch_all() @@ -27,13 +26,12 @@ def __init__( zmq_proxy_xpub_url=ait.SERVER_DEFAULT_XPUB_URL, **kwargs, ): - self.context = zmq_context # open PUB socket & connect to broker self.pub = self.context.socket(zmq.PUB) self.pub.connect(zmq_proxy_xsub_url.replace("*", "localhost")) - if 'listener' in kwargs and isinstance(kwargs['listener'], int) : - kwargs['listener'] = "127.0.0.1:"+str(kwargs['listener']) + if "listener" in kwargs and isinstance(kwargs["listener"], int): + kwargs["listener"] = "127.0.0.1:" + str(kwargs["listener"]) # calls gevent.Greenlet or gs.DatagramServer __init__ super(ZMQClient, self).__init__(**kwargs) @@ -89,7 +87,6 @@ def __init__( zmq_proxy_xpub_url=ait.SERVER_DEFAULT_XPUB_URL, **kwargs, ): - super(ZMQInputClient, self).__init__( zmq_context, zmq_proxy_xsub_url, zmq_proxy_xpub_url ) @@ -134,7 +131,6 @@ def __init__( zmq_proxy_xpub_url=ait.SERVER_DEFAULT_XPUB_URL, **kwargs, ): - super(PortOutputClient, self).__init__( zmq_context, zmq_proxy_xsub_url, zmq_proxy_xpub_url ) @@ -162,7 +158,6 @@ def __init__( zmq_proxy_xpub_url=ait.SERVER_DEFAULT_XPUB_URL, **kwargs, ): - if "input" in kwargs and type(kwargs["input"][0]) is int: super(PortInputClient, self).__init__( zmq_context, diff --git a/ait/core/server/config.py b/ait/core/server/config.py index 7835362c..4b564ec3 100644 --- a/ait/core/server/config.py +++ b/ait/core/server/config.py @@ -1,4 +1,3 @@ -import ait.core import ait.core.server @@ -6,6 +5,7 @@ class ZmqConfig: """ Configuration methods associated with ZeroMQ """ + @staticmethod def get_xsub_url(): return ait.config.get("server.xsub", ait.SERVER_DEFAULT_XSUB_URL) diff --git a/ait/core/server/handler.py b/ait/core/server/handler.py index 9182c7d2..24d33c22 100755 --- a/ait/core/server/handler.py +++ b/ait/core/server/handler.py @@ -1,4 +1,5 @@ -from abc import ABCMeta, abstractmethod +from abc import ABCMeta +from abc import abstractmethod class Handler(object): diff --git a/ait/core/server/handlers/ccsds_packet_handler.py b/ait/core/server/handlers/ccsds_packet_handler.py index f9335e89..92e80a75 100644 --- a/ait/core/server/handlers/ccsds_packet_handler.py +++ b/ait/core/server/handlers/ccsds_packet_handler.py @@ -1,9 +1,9 @@ -import pickle import binascii -import ait.core.log +import pickle -from ait.core.server.handler import Handler +import ait.core.log from ait.core import tlm +from ait.core.server.handler import Handler class CCSDSPacketHandler(Handler): diff --git a/ait/core/server/handlers/packet_handler.py b/ait/core/server/handlers/packet_handler.py index 1ec845dc..c78f1cea 100644 --- a/ait/core/server/handlers/packet_handler.py +++ b/ait/core/server/handlers/packet_handler.py @@ -1,7 +1,7 @@ import pickle -from ait.core.server.handler import Handler from ait.core import tlm +from ait.core.server.handler import Handler class PacketHandler(Handler): diff --git a/ait/core/server/plugins/PacketAccumulator.py b/ait/core/server/plugins/PacketAccumulator.py index 17479b6a..c744d4a5 100644 --- a/ait/core/server/plugins/PacketAccumulator.py +++ b/ait/core/server/plugins/PacketAccumulator.py @@ -1,9 +1,18 @@ +from gevent import Greenlet +from gevent import sleep + from ait.core.server.plugins import Plugin -from gevent import Greenlet, sleep class PacketAccumulator(Plugin): - def __init__(self, inputs=None, outputs=None, zmq_args=None, timer_seconds=1, max_size_octets=1024): + def __init__( + self, + inputs=None, + outputs=None, + zmq_args=None, + timer_seconds=1, + max_size_octets=1024, + ): super().__init__(inputs, outputs, zmq_args) self.packet_queue = [] diff --git a/ait/core/server/plugins/PacketPadder.py b/ait/core/server/plugins/PacketPadder.py index d5bbf35a..9b029fa3 100644 --- a/ait/core/server/plugins/PacketPadder.py +++ b/ait/core/server/plugins/PacketPadder.py @@ -1,15 +1,19 @@ -from ait.core.server.plugins import Plugin from ait.core import log +from ait.core.server.plugins import Plugin class PacketPadder(Plugin): - def __init__(self, inputs=None, outputs=None, zmq_args=None, pad_octets=0, **kwargs): + def __init__( + self, inputs=None, outputs=None, zmq_args=None, pad_octets=0, **kwargs + ): if pad_octets >= 0: self.size_pad_octets = pad_octets else: self.size_pad_octets = 0 - log.error(f"PacketPadder -> Pad value{pad_octets} octets must be a \ - positive integer! Bypassing padding!") + log.error( + f"PacketPadder -> Pad value{pad_octets} octets must be a \ + positive integer! Bypassing padding!" + ) super().__init__(inputs, outputs, zmq_args) def process(self, data, topic=None): diff --git a/ait/core/server/plugins/apid_routing.py b/ait/core/server/plugins/apid_routing.py index f2f4e317..ff486088 100644 --- a/ait/core/server/plugins/apid_routing.py +++ b/ait/core/server/plugins/apid_routing.py @@ -1,6 +1,6 @@ """ Implements a plugin which routes CCSDS packets by APID -""" +""" # fmt: skip import os import yaml diff --git a/ait/core/server/plugins/data_archive.py b/ait/core/server/plugins/data_archive.py index 6eb86448..7000a659 100644 --- a/ait/core/server/plugins/data_archive.py +++ b/ait/core/server/plugins/data_archive.py @@ -11,12 +11,10 @@ # 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. - -from collections import defaultdict -import pickle import importlib +import pickle +from collections import defaultdict -import gevent import gevent.monkey gevent.monkey.patch_all() diff --git a/ait/core/server/plugins/limit_monitor.py b/ait/core/server/plugins/limit_monitor.py index 873b64d2..5cfe47a5 100644 --- a/ait/core/server/plugins/limit_monitor.py +++ b/ait/core/server/plugins/limit_monitor.py @@ -11,11 +11,9 @@ # 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. - -from collections import defaultdict import pickle +from collections import defaultdict -import gevent import gevent.monkey gevent.monkey.patch_all() diff --git a/ait/core/server/plugins/openmct.py b/ait/core/server/plugins/openmct.py index 190e6b91..d757750a 100644 --- a/ait/core/server/plugins/openmct.py +++ b/ait/core/server/plugins/openmct.py @@ -11,7 +11,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 Plugin for OpenMCT Telemetry service @@ -20,16 +19,14 @@ framework for realtime and, eventually, historical telemetry from AIT. """ - -import pickle import datetime import json +import pickle import random import struct import sys import webbrowser -import gevent import gevent.monkey gevent.monkey.patch_all() @@ -44,10 +41,11 @@ from ait.core.server.plugin import Plugin -class ManagedWebSocket(): +class ManagedWebSocket: """ A data structure to maintain state for OpenMCT websockets """ + id_counter = 0 # to assign unique ids PACKET_ID_WILDCARD = "*" @@ -141,12 +139,12 @@ def create_subscribed_packet(self, omc_packet): :param omc_packet: Full OpenMCT packet with all fields :return: New modified packet if any match in fields, else None """ - packet_id = omc_packet['packet'] + packet_id = omc_packet["packet"] if not self.accepts_packet(packet_id): return None # Grab the original field data dict - orig_fld_dict = omc_packet['data'] + orig_fld_dict = omc_packet["data"] if not orig_fld_dict: return None @@ -160,7 +158,7 @@ def create_subscribed_packet(self, omc_packet): filt_fld_dict = {k: v for k, v in orig_fld_dict.items() if k in field_set} # If filtered dict is non-empty, then build new packet for return if filt_fld_dict: - sub_pkt = {'packet': packet_id, 'data': filt_fld_dict} + sub_pkt = {"packet": packet_id, "data": filt_fld_dict} return sub_pkt @@ -229,7 +227,9 @@ def format_tlmdict_for_openmct(ait_tlm_dict): mct_field_dict = dict() # mct_field_dict['key'] = ait_pkt_id + "." + ait_field_id - mct_field_dict["key"] = DictUtils.create_mct_pkt_id(ait_pkt_id, ait_field_id) + mct_field_dict["key"] = DictUtils.create_mct_pkt_id( + ait_pkt_id, ait_field_id + ) mct_field_dict["name"] = ait_field_def.name mct_field_dict["name"] = ait_pkt_id + ":" + ait_field_def.name @@ -298,7 +298,7 @@ def create_mct_fieldmap(ait_pkt_fld_def): tmax = 2 ** (tnbits - 1) tmin = -1 * (tmax - 1) elif not tstring: - tmax = 2 ** tnbits - 1 + tmax = 2**tnbits - 1 tmin = 0 if tmin is not None: @@ -357,7 +357,7 @@ def __init__( outputs, zmq_args=None, datastore="ait.core.db.InfluxDBBackend", - **kwargs + **kwargs, ): """ Params: @@ -457,7 +457,6 @@ def load_database(self, **kwargs): dbconn = None if self._databaseEnabled: - # Perform sanity check that database config exists somewhere db_cfg = ait.config.get("database", kwargs.get("database", None)) if not db_cfg: @@ -506,12 +505,16 @@ def process(self, input_data, topic=None): self._process_telem_msg(tlm_packet) processed = True else: - log.error("OpenMCT Plugin received telemetry message with unknown " - f"packet id {pkt_id}. Skipping input...") + log.error( + "OpenMCT Plugin received telemetry message with unknown " + f"packet id {pkt_id}. Skipping input..." + ) except Exception as e: log.error(f"OpenMCT Plugin: {e}") - log.error("OpenMCT Plugin received input_data that it is unable to " - "process. Skipping input ...") + log.error( + "OpenMCT Plugin received input_data that it is unable to " + "process. Skipping input ..." + ) return processed @@ -633,12 +636,11 @@ def get_realtime_tlm_original_dumb(self): try: while not websocket.closed: - message = None with Timeout(3, False): message = websocket.receive() if message: - self.dbg_message("Received websocket message: "+message) + self.dbg_message("Received websocket message: " + message) else: self.dbg_message("Received NO websocket message") @@ -651,7 +653,9 @@ def get_realtime_tlm_original_dumb(self): ait_pkt = ait.core.tlm.Packet(pkt_defn, data=data) - packet_id, openmct_pkt = DictUtils.format_tlmpkt_for_openmct(ait_pkt) + packet_id, openmct_pkt = DictUtils.format_tlmpkt_for_openmct( + ait_pkt + ) openmct_pkt_jsonstr = json.dumps( openmct_pkt, default=self.datetime_jsonifier @@ -713,7 +717,9 @@ def manage_web_socket(self, mws): managed set and this method returns :param mws: Managed web-socket instance """ - self.dbg_message(f"Adding record for new web-socket ID:{mws.id} with IP: {mws.client_ip}") + self.dbg_message( + f"Adding record for new web-socket ID:{mws.id} with IP: {mws.client_ip}" + ) self._socket_set.add(mws) while mws.is_alive: @@ -724,7 +730,7 @@ def manage_web_socket(self, mws): gsleep(AITOpenMctPlugin.DEFAULT_WEBSOCKET_CHECK_SLEEP_SECS) # Web-socket is considered closed, so remove from set and return - rem_msg_state = 'err' if mws.is_error else 'closed' + rem_msg_state = "err" if mws.is_error else "closed" self.dbg_message(f"Removing {rem_msg_state} web-socket record ID {mws.id}") self._socket_set.remove(mws) @@ -740,8 +746,10 @@ def get_historical_tlm(self, mct_pkt_id): # Set the content type of response for OpenMct to know its JSON bottle.response.content_type = "application/json" - self.dbg_message("Received request for historical tlm: " - f"Ids={mct_pkt_id} Start={start_time_ms} End={end_time_ms}") + self.dbg_message( + "Received request for historical tlm: " + f"Ids={mct_pkt_id} Start={start_time_ms} End={end_time_ms}" + ) # The tutorial indicated that this could be a comma-separated list of ids... # If its a single, then this will create a list with one entry @@ -754,8 +762,10 @@ def get_historical_tlm(self, mct_pkt_id): # Dump results to JSON string json_result = json.dumps(results) - self.dbg_message(f"Result for historical tlm ( {start_time_ms} " - f"- {end_time_ms} ): {json_result}") + self.dbg_message( + f"Result for historical tlm ( {start_time_ms} " + f"- {end_time_ms} ): {json_result}" + ) return json_result @@ -851,8 +861,9 @@ def get_historical_tlm_for_packet_fields( end_timestamp_secs, tz=datetime.timezone.utc ) - query_args_str = f"Packets = {packet_ids}; Start = {start_date};" \ - f" End = {end_date}" + query_args_str = ( + f"Packets = {packet_ids}; Start = {start_date};" f" End = {end_date}" + ) self.dbg_message(f"Query args : {query_args_str}") # default response is empty @@ -880,15 +891,16 @@ def get_historical_tlm_for_packet_fields( res_pkts = list(ait_db_result.get_packets()) # Debug result size - self.dbg_message(f"Number of results for query " - f"{query_args_str} : {len(res_pkts)}") + self.dbg_message( + f"Number of results for query " + f"{query_args_str} : {len(res_pkts)}" + ) except Exception as e: log.error("[OpenMCT] Database query failed. Error: " + str(e)) return None for cur_pkt_time, cur_pkt in res_pkts: - # Convert datetime to Javascript timestamp (in milliseconds) cur_timestamp_sec = datetime.datetime.timestamp(cur_pkt_time) unix_timestamp_msec = int(cur_timestamp_sec) * 1000 @@ -941,7 +953,6 @@ def mimic_tlm(self, ait_tlm_pkt_name, ait_tlm_pkt_fill=None): info_msg = "" while True: - # Special handling for simply integer based packet, others will # have all 0 zero if ait_pkt_defn.name == "1553_HS_Packet": @@ -994,7 +1005,9 @@ def poll_telemetry(self): """ try: self.dbg_message("Polling Telemetry queue...") - ait_pkt = self._tlmQueue.popleft(timeout=self.DEFAULT_TELEM_QUEUE_TIMEOUT_SECS) + ait_pkt = self._tlmQueue.popleft( + timeout=self.DEFAULT_TELEM_QUEUE_TIMEOUT_SECS + ) openmct_pkt = DictUtils.format_tlmpkt_for_openmct(ait_pkt) self.dbg_message(f"Broadcasting {openmct_pkt} to managed web-sockets...") self.broadcast_packet(openmct_pkt) @@ -1023,8 +1036,9 @@ def broadcast_packet(self, openmct_pkt): openmct_pkt_id = openmct_pkt["packet"] for mws in self._socket_set: - pkt_emitted_by_cur = self.send_socket_pkt_mesg(mws, - openmct_pkt_id, openmct_pkt) + pkt_emitted_by_cur = self.send_socket_pkt_mesg( + mws, openmct_pkt_id, openmct_pkt + ) pkt_emitted_by_any = pkt_emitted_by_cur or pkt_emitted_by_any return pkt_emitted_by_any @@ -1051,10 +1065,11 @@ def send_socket_pkt_mesg(self, mws, pkt_id, mct_pkt): subscribed_pkt = mws.create_subscribed_packet(mct_pkt) # If that new packet still has fields, stringify and send if subscribed_pkt: - pkt_mesg = json.dumps(subscribed_pkt, - default=self.datetime_jsonifier) - self.dbg_message("Sending realtime telemetry web-socket msg " - f"to websocket {mws.id}: {pkt_mesg}") + pkt_mesg = json.dumps(subscribed_pkt, default=self.datetime_jsonifier) + self.dbg_message( + "Sending realtime telemetry web-socket msg " + f"to websocket {mws.id}: {pkt_mesg}" + ) self.managed_web_socket_send(mws, pkt_mesg) return True @@ -1064,11 +1079,11 @@ def send_socket_pkt_mesg(self, mws, pkt_id, mct_pkt): @staticmethod def managed_web_socket_recv(mws): - ''' + """ Attempts to read message from the websocket with timeout. :param mws: Managed web-socket instance :return: Message retrieved from underlying-websocket, or None - ''' + """ message = None try: with Timeout(AITOpenMctPlugin.DEFAULT_WS_RECV_TIMEOUT_SECS, False): @@ -1080,16 +1095,18 @@ def managed_web_socket_recv(mws): @staticmethod def managed_web_socket_send(mws, message): - ''' + """ Sends message to underlying web-socket :param mws: Managed web-socket instance :param message: Message to be sent - ''' + """ if mws.is_alive: try: mws.web_socket.send(message) except geventwebsocket.WebSocketError as wserr: - log.warn(f"Error while writing to web-socket {mws.id}; Message:'{message}'; Error: {wserr}") + log.warn( + f"Error while writing to web-socket {mws.id}; Message:'{message}'; Error: {wserr}" + ) mws.set_error() # --------------------------------------------------------------------- @@ -1148,13 +1165,15 @@ def process_websocket_mesg(self, mws, message): """ msg_parts = message.split(" ", 1) directive = msg_parts[0] - if directive == 'close': - self.dbg_message(f"Received 'close' message. Marking web-socket ID {mws.id} as closed") + if directive == "close": + self.dbg_message( + f"Received 'close' message. Marking web-socket ID {mws.id} as closed" + ) mws.is_closed = True - elif directive == 'subscribe' and len(msg_parts) > 1: + elif directive == "subscribe" and len(msg_parts) > 1: self.dbg_message(f"Subscribing websocket {mws.id} to: {msg_parts[1]}") mws.subscribe_field(msg_parts[1]) - elif directive == 'unsubscribe': + elif directive == "unsubscribe": self.dbg_message(f"Unsubscribing websocket {mws.id} from: {msg_parts[1]}") mws.unsubscribe_field(msg_parts[1]) else: diff --git a/ait/core/server/process.py b/ait/core/server/process.py index a02c1e01..0bdd26f2 100644 --- a/ait/core/server/process.py +++ b/ait/core/server/process.py @@ -1,14 +1,14 @@ -import zmq.green as zmq - import copy import sys + import gevent import gipc # type: ignore import setproctitle # type: ignore +import zmq.green as zmq -from ait.core import log -from .plugin import Plugin from .broker import Broker +from .plugin import Plugin +from ait.core import log class PluginsProcess(object): @@ -55,8 +55,9 @@ def get_plugin_names(self, use_short_names=True): Returns a list of plugin names (short versions) managed by instance Returns: List of plugin names """ - return [pi.short_name if use_short_names else pi.name - for pi in self._plugin_infos] + return [ + pi.short_name if use_short_names else pi.name for pi in self._plugin_infos + ] def get_plugin_outputs(self, use_short_names=True): """ @@ -93,8 +94,9 @@ def add_plugin_info(self, plugin_info): RuntimeError if the process is already running """ if self._spawned: - raise RuntimeError("Cannot add plugin info after process has " - "been spawned") + raise RuntimeError( + "Cannot add plugin info after process has " "been spawned" + ) if plugin_info is not None: self._plugin_infos.append(plugin_info) @@ -147,7 +149,6 @@ def start_plugins_process(namespace, plugin_info_list): @staticmethod def load_plugins(namespace, plugin_info_list): - # List of plugins to be returned plugin_list = [] @@ -161,17 +162,23 @@ def load_plugins(namespace, plugin_info_list): try: plugin = PluginsProcess.create_plugin(p_info, proc_context) if plugin is None: - log.info(f"Unable to create {plugin_name}, will not be " - f"added to {namespace} plugins list") + log.info( + f"Unable to create {plugin_name}, will not be " + f"added to {namespace} plugins list" + ) else: - log.debug(f"Adding process-greenlet '{plugin_name}' to " - f"'{namespace}' plugins list") + log.debug( + f"Adding process-greenlet '{plugin_name}' to " + f"'{namespace}' plugins list" + ) plugin_list.append(plugin) except Exception: exc_type, exc_value, tb = sys.exc_info() - log.error(f"{exc_type} creating plugin '{plugin_name}'' for " - f"process '{namespace}'': {exc_value}") + log.error( + f"{exc_type} creating plugin '{plugin_name}'' for " + f"process '{namespace}'': {exc_value}" + ) return plugin_list @@ -229,8 +236,7 @@ def start_and_join_all(namespace, plugin_list): # Start all of the plugin-gevents for greenlet in plugin_list: - log.info(f"Starting {greenlet} greenlet in process " - f"'{namespace}'...") + log.info(f"Starting {greenlet} greenlet in process " f"'{namespace}'...") greenlet.start() # Wait for Plugins to finish diff --git a/ait/core/server/stream.py b/ait/core/server/stream.py index dd789953..86b1a2ae 100644 --- a/ait/core/server/stream.py +++ b/ait/core/server/stream.py @@ -1,8 +1,10 @@ import ait.core.log -from .client import ZMQInputClient, PortInputClient, PortOutputClient +from .client import PortInputClient +from .client import PortOutputClient +from .client import ZMQInputClient -class Stream(): +class Stream: """ This is the base Stream class that all streams will inherit from. It calls its handlers to execute on all input messages sequentially, diff --git a/ait/core/server/utils.py b/ait/core/server/utils.py index dc651d1c..02eb49ee 100644 --- a/ait/core/server/utils.py +++ b/ait/core/server/utils.py @@ -11,8 +11,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. - - import pickle diff --git a/ait/core/util.py b/ait/core/util.py index d0e6d3b0..74f7ce13 100755 --- a/ait/core/util.py +++ b/ait/core/util.py @@ -1,5 +1,4 @@ #!/usr/bin/env python2.7 - # Advanced Multi-Mission Operations System (AMMOS) Instrument Toolkit (AIT) # Bespoke Link to Instruments and Small Satellites (BLISS) # @@ -13,23 +12,20 @@ # 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 Utilities The ait.core.util module provides general utility functions. """ - import os +import pickle import pydoc import stat import sys -import time -import zlib import tempfile +import time import warnings - -import pickle +import zlib import ait from ait.core import log @@ -82,7 +78,7 @@ def load(self): if self.dirty: self._dict = self._loader(self.filename) update_cache(self.filename, self.cachename, self._dict) - log.info(f'Loaded new pickle file: {self.cachename}') + log.info(f"Loaded new pickle file: {self.cachename}") else: with open(self.cachename, "rb") as stream: self._dict = pickle.load(stream) @@ -122,11 +118,11 @@ def check_yaml_timestamps(yaml_file_name, cache_name): """ # If no pickle cache exists return True to make a new one. if not os.path.exists(cache_name): - log.debug('No pickle cache exists, make a new one') + log.debug("No pickle cache exists, make a new one") return True # Has the yaml config file has been modified since the creation of the pickle cache if os.path.getmtime(yaml_file_name) > os.path.getmtime(cache_name): - log.info(f'{yaml_file_name} modified - make a new binary pickle cache file.') + log.info(f"{yaml_file_name} modified - make a new binary pickle cache file.") return True # Get the directory of the yaml config file to be parsed dir_name = os.path.dirname(yaml_file_name) @@ -136,12 +132,13 @@ def check_yaml_timestamps(yaml_file_name, cache_name): for line in file: if not line.strip().startswith("#") and "!include" in line: check = check_yaml_timestamps( - os.path.join(dir_name, line.strip().split(" ")[2]), cache_name) + os.path.join(dir_name, line.strip().split(" ")[2]), cache_name + ) if check: return True except RecursionError as e: log.info( - f'ERROR: {e}: Infinite loop: check that yaml config files are not looping ' + f"ERROR: {e}: Infinite loop: check that yaml config files are not looping " f'back and forth on one another through the "!include" statements.' ) return False @@ -162,7 +159,7 @@ def update_cache(yaml_file_name, cache_file_name, object_to_serialize): """ - msg = f'Saving updates from more recent {yaml_file_name} to {cache_file_name}.' + msg = f"Saving updates from more recent {yaml_file_name} to {cache_file_name}." log.info(msg) with open(cache_file_name, "wb") as output: pickle.dump(object_to_serialize, output, -1) @@ -520,6 +517,7 @@ class TestFile: Whether the above assert passes or throws AssertionError, filename will be deleted. """ + __test__ = False def __init__(self, data, options): diff --git a/setup.cfg b/setup.cfg index 733a9057..8e2cb597 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,6 +15,7 @@ omit = */_version.py,*/__init__.py,*/bin/*,*/test/* [flake8] extend-exclude = versioneer.py,_version.py,docs,doc,tests,test,setup.py +max-line-length = 120 # Line breaks before/after a binary operator, allow them since it # is not clear how to resolve while making code readable diff --git a/tests/ait/core/__init__.py b/tests/ait/core/__init__.py index d7d02924..44688757 100644 --- a/tests/ait/core/__init__.py +++ b/tests/ait/core/__init__.py @@ -11,7 +11,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 Unit and Functional Tests""" import logging diff --git a/tests/ait/core/server/test_apid_routing.py b/tests/ait/core/server/test_apid_routing.py index 5dd12263..d1f00424 100644 --- a/tests/ait/core/server/test_apid_routing.py +++ b/tests/ait/core/server/test_apid_routing.py @@ -1,6 +1,6 @@ import unittest - from unittest.mock import patch + from ait.core import log from ait.core.server.plugins.apid_routing import APIDRouter from ait.core.util import TestFile @@ -11,11 +11,11 @@ def __init__(self, apid=0): self.apid = apid -def create_test_dict(number_of_packets = 150): +def create_test_dict(number_of_packets=150): test_dict = {} - for i in range(1, number_of_packets+1): + for i in range(1, number_of_packets + 1): packet_name = f"Packet_{i}" - test_dict[packet_name] = TestPacket(apid = i) + test_dict[packet_name] = TestPacket(apid=i) return test_dict @@ -40,45 +40,61 @@ def routing_table_yaml(): pass with TestFile(routing_table_yaml.__doc__, "wt") as filename: + def new_init(self, routing_table=None, default_topic=None): self.default_topic = default_topic - if 'path' in routing_table: - self.routing_table_object = self.load_table_yaml(routing_table['path'], create_test_dict(10)) + if "path" in routing_table: + self.routing_table_object = self.load_table_yaml( + routing_table["path"], create_test_dict(10) + ) else: self.routing_table_object = None log.error("no path specified for routing table") if self.routing_table_object is None: log.error("Unable to load routing table .yaml file") - with patch.object(APIDRouter, '__init__', new_init): - router_plugin_instance = APIDRouter(routing_table={'path': filename}, default_topic= "test_default_topic") + with patch.object(APIDRouter, "__init__", new_init): + router_plugin_instance = APIDRouter( + routing_table={"path": filename}, default_topic="test_default_topic" + ) def test_routing_table(self): test_routing_table_dict = { - 1: ['test_default_topic', 'telem_topic_1'], - 2: ['test_default_topic', 'telem_topic_2'], - 3: ['test_default_topic'], - 4: ['test_default_topic', 'telem_topic_2'], - 5: ['test_default_topic', 'telem_topic_2'], - 6: ['test_default_topic'], - 7: ['test_default_topic', 'telem_topic_1', 'telem_topic_2'], - 8: ['test_default_topic', 'telem_topic_2'], - 9: ['test_default_topic', 'telem_topic_2'], - 10: ['test_default_topic'] - } - self.assertEqual(self.router_plugin_instance.routing_table_object, test_routing_table_dict) + 1: ["test_default_topic", "telem_topic_1"], + 2: ["test_default_topic", "telem_topic_2"], + 3: ["test_default_topic"], + 4: ["test_default_topic", "telem_topic_2"], + 5: ["test_default_topic", "telem_topic_2"], + 6: ["test_default_topic"], + 7: ["test_default_topic", "telem_topic_1", "telem_topic_2"], + 8: ["test_default_topic", "telem_topic_2"], + 9: ["test_default_topic", "telem_topic_2"], + 10: ["test_default_topic"], + } + self.assertEqual( + self.router_plugin_instance.routing_table_object, test_routing_table_dict + ) def test_apid_extraction1(self): - test_bytearray = bytearray(b'\x00\x1f\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0') - self.assertEqual(self.router_plugin_instance.get_packet_apid(test_bytearray), 31) + test_bytearray = bytearray(b"\x00\x1f\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0") + self.assertEqual( + self.router_plugin_instance.get_packet_apid(test_bytearray), 31 + ) def test_apid_extraction2(self): - test_bytearray = bytearray(b'\x01\x03\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0') - self.assertEqual(self.router_plugin_instance.get_packet_apid(test_bytearray), 259) + test_bytearray = bytearray(b"\x01\x03\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0") + self.assertEqual( + self.router_plugin_instance.get_packet_apid(test_bytearray), 259 + ) def test_get_topics(self): - test_bytearray = bytearray(b'\x00\x07\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0') - test_bytearray_apid = self.router_plugin_instance.get_packet_apid(test_bytearray) - expected_topics = ['test_default_topic', 'telem_topic_1', 'telem_topic_2'] - self.assertEqual(self.router_plugin_instance.routing_table_object[test_bytearray_apid], expected_topics) + test_bytearray = bytearray(b"\x00\x07\x75\x94\xfa\xdc\x43\x90\x9a\x8c\xff\xe0") + test_bytearray_apid = self.router_plugin_instance.get_packet_apid( + test_bytearray + ) + expected_topics = ["test_default_topic", "telem_topic_1", "telem_topic_2"] + self.assertEqual( + self.router_plugin_instance.routing_table_object[test_bytearray_apid], + expected_topics, + ) diff --git a/tests/ait/core/server/test_handler.py b/tests/ait/core/server/test_handler.py index f4d32252..5025294a 100644 --- a/tests/ait/core/server/test_handler.py +++ b/tests/ait/core/server/test_handler.py @@ -8,7 +8,6 @@ class TestCCSDSPacketCheck(unittest.TestCase): - # Check if packet length is at least 7 bytes def test_ccsds_packet_length(self): handler = CCSDSPacketHandler(packet_types={"01011100111": "CCSDS_HEADER"}) diff --git a/tests/ait/core/test_cmd.py b/tests/ait/core/test_cmd.py index 1a7d3a61..dab458be 100644 --- a/tests/ait/core/test_cmd.py +++ b/tests/ait/core/test_cmd.py @@ -12,6 +12,7 @@ # or other export authority as may be required before exporting such # information to foreign countries or providing access to foreign persons. import gevent.monkey + gevent.monkey.patch_all() import struct @@ -142,30 +143,32 @@ def testGetDefaultDict(): assert cmddict is not None assert isinstance(cmddict, cmd.CmdDict) + def testGetDefaultDictWithExtension(testGetDefaultDictWithExtension_setup_teardown): cd = cmd.getDefaultDict() assert type(cd) == TestCmdDict + @pytest.fixture def testGetDefaultDictWithExtension_setup_teardown(): - cfg_yml = ''' + cfg_yml = """ default: extensions: ait.core.cmd.CmdDict: tests.ait.core.test_cmd.TestCmdDict - ''' + """ saved_config = ait.config ait.config = cfg.AitConfig(data=cfg_yml) - setattr(cmd, 'DefaultDict', None) # Reset DefaultDict being cached - importlib.reload(cmd) # Recreate createCmdDict method + setattr(cmd, "DefaultDict", None) # Reset DefaultDict being cached + importlib.reload(cmd) # Recreate createCmdDict method yield ait.config = saved_config - setattr(cmd, 'DefaultDict', None) # Reset DefaultDict being cached - importlib.reload(cmd) # Recreate createCmdDict method - importlib.reload(tlm) # Also reload tlm default schema + setattr(cmd, "DefaultDict", None) # Reset DefaultDict being cached + importlib.reload(cmd) # Recreate createCmdDict method + importlib.reload(tlm) # Also reload tlm default schema class TestCmdDict(cmd.CmdDict): - __test__ = False # prevents pytest PytestCollectionWarning + __test__ = False # prevents pytest PytestCollectionWarning def __init__(self, *args, **kwargs): super(TestCmdDict, self).__init__(*args, **kwargs) diff --git a/tests/ait/core/test_db.py b/tests/ait/core/test_db.py index 9eb8d0f1..3ee59773 100644 --- a/tests/ait/core/test_db.py +++ b/tests/ait/core/test_db.py @@ -446,7 +446,6 @@ def test_query_packet_time_inclusion(self, importlib_mock): assert isinstance(res_pkts[0], tuple) for i, test_data in enumerate(ret_data[0][1]): - assert dmc.rfc3339_str_to_datetime(test_data["time"]) == res_pkts[i][0] assert res_pkts[i][1].Voltage_A == i @@ -663,7 +662,10 @@ def test_sqlite_insert(self, importlib_mock): 'INSERT INTO "Packet1" (PKTDATA, time) VALUES (?, ?)' in sqlbackend._conn.execute.call_args[0] ) - assert (now.strftime(dmc.RFC3339_Format) == sqlbackend._conn.execute.call_args[0][1][1]) + assert ( + now.strftime(dmc.RFC3339_Format) + == sqlbackend._conn.execute.call_args[0][1][1] + ) os.remove(self.test_yaml_file) diff --git a/tests/ait/core/test_pcap.py b/tests/ait/core/test_pcap.py index 11ad7722..8a76bf96 100644 --- a/tests/ait/core/test_pcap.py +++ b/tests/ait/core/test_pcap.py @@ -11,18 +11,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. - import datetime import os import struct -import warnings import time - +import warnings from unittest import mock from gevent import monkey -from ait.core import dmc, pcap +from ait.core import dmc +from ait.core import pcap from ait.core.util import TestFile monkey.patch_all() @@ -32,7 +31,7 @@ with warnings.catch_warnings(): warnings.simplefilter("ignore") - with TestFile('', "wb") as filename: + with TestFile("", "wb") as filename: TmpFilename = filename diff --git a/tests/ait/core/test_table.py b/tests/ait/core/test_table.py index a02f3047..f5eae461 100644 --- a/tests/ait/core/test_table.py +++ b/tests/ait/core/test_table.py @@ -279,7 +279,7 @@ def test_enum_decode(self): out_file.write(encoded) with open(temp_bin_file, "rb") as out_file: - decoded = defn.decode(file_in=out_file) + decoded = defn.decode(file_in=out_file) # Check header assert decoded[0][0] == 13 diff --git a/tests/ait/core/test_tlm.py b/tests/ait/core/test_tlm.py index 8bff2ec0..b1724698 100644 --- a/tests/ait/core/test_tlm.py +++ b/tests/ait/core/test_tlm.py @@ -12,13 +12,13 @@ # or other export authority as may be required before exporting such # information to foreign countries or providing access to foreign persons. # gevent.monkey.patch_all() - import csv import os -import pytest import struct +import pytest from gevent import monkey + monkey.patch_all() from ait.core import tlm diff --git a/tests/ait/core/test_val.py b/tests/ait/core/test_val.py index 8d497d9a..c1731fb2 100644 --- a/tests/ait/core/test_val.py +++ b/tests/ait/core/test_val.py @@ -12,6 +12,7 @@ # or other export authority as may be required before exporting such # information to foreign countries or providing access to foreign persons. import gevent.monkey + gevent.monkey.patch_all() import os @@ -204,6 +205,7 @@ def test_procces_with_single_doc(self, pretty_mock): assert pretty_mock.called pretty_mock.assert_called_with(1, 3, error, messages) + def validate_schema(args): msgs = []