Skip to content

Commit 575d563

Browse files
authored
Merge pull request #317 from akrherz/gh316_rr3_update
Sundry updates
2 parents 8c49273 + bcc2016 commit 575d563

File tree

16 files changed

+124
-40
lines changed

16 files changed

+124
-40
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ repos:
1010
types: [python]
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: "v0.14.14"
13+
rev: "v0.15.0"
1414
hooks:
1515
- id: ruff
1616
args: [--fix, --exit-non-zero-on-fix]
1717
- id: ruff-format
1818

1919
- repo: https://github.com/tox-dev/pyproject-fmt
20-
rev: 'v2.11.1'
20+
rev: 'v2.12.1'
2121
hooks:
2222
- id: pyproject-fmt
2323

conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""For testing."""
22

3-
# 3rd party
3+
import sys
4+
45
import pytest
6+
from twisted.python import log
57

68
from pywwa import CTX, CTX_DEFAULTS
79
from pywwa.database import get_dbconnc
@@ -10,6 +12,7 @@
1012
# pytest + twisted + click == too much magic for poor me
1113
# So, this effectively disables reactor.stop() from working
1214
CTX_DEFAULTS["shutdown_delay"] = 1800
15+
log.startLogging(sys.stdout)
1316

1417

1518
@pytest.fixture(autouse=True)

examples/SHEF/RR3MPX_1.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
000
2+
SRUS53 KMPX 031510
3+
RR3MPX
4+
WxCoder
5+
.A LCHM5 260203 C DH0800/TX 19/TN -6/TA 0/PP 0.00
6+
.A1 SF 0.0/SD 4/SW 3.0/DC2602030907
7+

examples/SHEF/RR3MPX_2.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
000
2+
SRUS53 KMPX 032100
3+
RR3MPX
4+
WxCoder
5+
.AR LCHM5 260203 C DH0800/TX 19/TN -6/TA 0/PP 0.00
6+
.AR1 SF 0.0/SD 4/SW M/DC2602031459
7+

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ lint.select = [
117117
lint.per-file-ignores."goes/*.py" = [
118118
"T201",
119119
]
120+
lint.per-file-ignores."tests/*.py" = [
121+
"T201",
122+
]
120123
lint.per-file-ignores."util/*.py" = [
121124
"T201",
122125
]

src/pywwa/common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@ def email_error(exp, message="", trimstr=100):
205205
msg["subject"] = (
206206
f"[pyWWA] {sys.argv[0].rsplit('/', maxsplit=1)[-1]} Traceback -- {hn}"
207207
)
208-
msg["From"] = SETTINGS.get("pywwa_errors_from", "ldm@localhost")
209-
msg["To"] = SETTINGS.get("pywwa_errors_to", "ldm@localhost")
208+
msg["From"] = SETTINGS.get("pywwa_errors_from", "root@localhost")
209+
msg["To"] = SETTINGS.get("pywwa_errors_to", "root@localhost")
210210
if not CTX["disable_email"]:
211211
df = smtp.sendmail(
212-
SETTINGS.get("pywwa_smtp", "smtp"), msg["From"], msg["To"], msg
212+
SETTINGS.get("pywwa_smtp", "localhost"),
213+
msg["From"],
214+
msg["To"],
215+
msg,
213216
)
214217
df.addErrback(LOG.error)
215218
else:

src/pywwa/workflows/nexrad3_attr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ def load_station_table(txn):
3333
LOG.info("Station Table size %s", len(ST.keys()))
3434

3535

36-
def process_data(data):
36+
def process_data(data: bytes) -> dict:
3737
"""I am called when data is ahoy"""
3838
bio = BytesIO()
3939
bio.write(data)
4040
bio.seek(0)
41-
process(bio)
41+
return process(bio)
4242

4343

44-
def process(bio):
44+
def process(bio: BytesIO) -> dict:
4545
"""Process our data, please"""
4646
l3 = Level3File(bio)
4747
ctx = {
@@ -57,7 +57,7 @@ def process(bio):
5757
if "text" in line:
5858
ctx["lines"].append(line["text"])
5959
df = PGCONN.runInteraction(really_process, ctx)
60-
df.addErrback(common.email_error, ctx)
60+
df.addErrback(common.email_error, str(ctx))
6161
return ctx
6262

6363

src/pywwa/workflows/shef.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pyiem.observation import Observation
1717
from pyiem.util import convert_value, utc
1818
from twisted.internet import reactor
19+
from twisted.internet.defer import Deferred
1920
from twisted.internet.task import LoopingCall, deferLater
2021

2122
# Local
@@ -361,11 +362,13 @@ def insert_raw_inbound(cursor, args) -> int:
361362
return cursor.rowcount
362363

363364

364-
def update_current_queue(element: SHEFElement, product_id: str):
365+
def update_current_queue(
366+
element: SHEFElement, product_id: str
367+
) -> Deferred | None:
365368
"""Update CURRENT_QUEUE with new data."""
366369
# We only want observations
367370
if element.type != "R":
368-
return
371+
return None
369372
args = (
370373
element.station,
371374
element.valid,
@@ -385,7 +388,7 @@ def update_current_queue(element: SHEFElement, product_id: str):
385388
key, dict(valid=element.valid, value=element.num_value, dirty=True)
386389
)
387390
if element.valid < cur["valid"]:
388-
return
391+
return None
389392
cur["valid"] = element.valid
390393
cur["depth"] = element.depth
391394
cur["value"] = element.num_value
@@ -395,6 +398,8 @@ def update_current_queue(element: SHEFElement, product_id: str):
395398
cur["product_id"] = product_id
396399
cur["dirty"] = True
397400

401+
return defer
402+
398403

399404
def process_site_time(prod, sid, ts, elements: list[SHEFElement]):
400405
"""Ingest for IEMAccess."""
@@ -532,7 +537,7 @@ def write_access_records_eb(err, records: list, iemid, entry: ACCESSDB_ENTRY):
532537
common.email_error(err, f"write_access_entry({entry.station}) got {err}")
533538

534539

535-
def process_data(text):
540+
def process_data(text: str):
536541
"""Callback when text is received."""
537542
prod = parser(text, utcnow=common.utcnow(), ugc_provider={})
538543
if prod.warnings:

src/pywwa/workflows/sps.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
from functools import partial
44

5-
# 3rd Party
65
import click
76
from pyiem.database import get_sqlalchemy_conn
87
from pyiem.nws.products.sps import parser
98
from pyiem.nws.ugc import UGCProvider
109

11-
# Local
1210
from pywwa import LOG, common
1311
from pywwa.database import get_database, load_nwsli
1412
from pywwa.ldm import bridge

src/pywwa/workflows/vtec.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313

1414
from functools import partial
1515

16-
# 3rd Party
1716
import click
1817
from pyiem.database import get_sqlalchemy_conn
1918
from pyiem.nws.products.vtec import parser as vtecparser
2019
from pyiem.nws.ugc import UGCProvider
2120
from twisted.mail.smtp import SMTPSenderFactory
2221

23-
# Local
2422
from pywwa import LOG, common
2523
from pywwa.database import get_database, load_nwsli
2624
from pywwa.ldm import bridge

0 commit comments

Comments
 (0)