From 6b397cbdf18c4257fc20d99fc15a9b0f258cde39 Mon Sep 17 00:00:00 2001 From: Hemna Date: Fri, 17 Nov 2023 13:34:10 -0500 Subject: [PATCH] pep8 fixes --- aprsd/packets/core.py | 25 +++---------------------- aprsd/packets/packet_list.py | 1 - aprsd/wsgi.py | 7 ++++--- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/aprsd/packets/core.py b/aprsd/packets/core.py index fd87c994..c9362d82 100644 --- a/aprsd/packets/core.py +++ b/aprsd/packets/core.py @@ -54,23 +54,11 @@ def _init_msgNo(): # noqa: N802 def factory_from_dict(packet_dict): pkt_type = get_packet_type(packet_dict) -# print(f"pkt_type {pkt_type}") if pkt_type: -# if pkt_type == 'unknown': -# # try to determine it by the raw -# raw = packet_dict.get('raw') -# if raw: -# import aprslib -# type = get_packet_type(aprslib.parse(raw)) -# print(f"raw type {type}") - cls = TYPE_LOOKUP[pkt_type] -# print(f"CLS {cls}") - return cls.from_dict(packet_dict) - def factory_from_json(packet_dict): pkt_type = get_packet_type(packet_dict) if pkt_type: @@ -97,7 +85,7 @@ class Packet(metaclass=abc.ABCMeta): # Fields related to sending packets out send_count: int = field(repr=False, default=0, compare=False, hash=False) retry_count: int = field(repr=False, default=3, compare=False, hash=False) - #last_send_time: datetime = field( + # last_send_time: datetime = field( # metadata=dc_json_config( # encoder=datetime.isoformat, # decoder=datetime.fromisoformat, @@ -106,7 +94,7 @@ class Packet(metaclass=abc.ABCMeta): # default_factory=_init_send_time, # compare=False, # hash=False - #) + # ) last_send_time: float = field(repr=False, default=0, compare=False, hash=False) last_send_attempt: int = field(repr=False, default=0, compare=False, hash=False) @@ -123,7 +111,6 @@ def json(self): """ get the json formated string """ - #return json.dumps(self.__dict__, cls=aprsd_json.EnhancedJSONEncoder) return self.to_json() def get(self, key, default=None): @@ -330,6 +317,7 @@ def __post__init__(self): def _build_payload(self): self.payload = f":{self.to_call.ljust(9)} :rej{self.msgNo}" + @dataclass_json @dataclass(unsafe_hash=True) class MessagePacket(Packet): @@ -478,13 +466,6 @@ def _build_raw(self): ) -@dataclass -class StatusPacket(Packet): - status: str = None - messagecapable: bool = False - comment: str = None - - @dataclass class MicEPacket(GPSPacket): messagecapable: bool = False diff --git a/aprsd/packets/packet_list.py b/aprsd/packets/packet_list.py index 87f67d82..3d75a07a 100644 --- a/aprsd/packets/packet_list.py +++ b/aprsd/packets/packet_list.py @@ -62,7 +62,6 @@ def _add(self, packet): def copy(self): return self.d.copy() - @property def maxlen(self): return self._maxlen diff --git a/aprsd/wsgi.py b/aprsd/wsgi.py index 63718372..0e873cc6 100644 --- a/aprsd/wsgi.py +++ b/aprsd/wsgi.py @@ -236,6 +236,7 @@ def plugins(): return "reloaded" + def _get_namespaces(): args = [] @@ -259,13 +260,13 @@ def generate_oslo(): generator.generate(CONF, string_out) return string_out.getvalue() + @auth.login_required @app.route("/oslo") def oslo(): return generate_oslo() - @auth.login_required @app.route("/save") def save(): @@ -407,8 +408,8 @@ def init_app(config_file=None, log_level=None): log_level = init_app( log_level="DEBUG", - #config_file="/config/aprsd.conf", - config_file = cli_helper.DEFAULT_CONFIG_FILE, + # config_file="/config/aprsd.conf", + config_file=cli_helper.DEFAULT_CONFIG_FILE, ) setup_logging(app, log_level) sio.register_namespace(LoggingNamespace("/logs"))