Skip to content

Commit

Permalink
Merge pull request #614 from akrherz/231215
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Dec 15, 2023
2 parents 1020301 + 44f99f7 commit 73c57c9
Show file tree
Hide file tree
Showing 68 changed files with 254 additions and 279 deletions.
2 changes: 1 addition & 1 deletion cgi-bin/request/gis/spc_outlooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def run(ctx, start_response):
return zio.getvalue()


@iemapp()
@iemapp(default_tz="UTC")
def application(environ, start_response):
"""Do something fun!"""
if "sts" not in environ:
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/gis/watchwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def do_excel(sql):
return bio.getvalue()


@iemapp()
@iemapp(default_tz="UTC")
def application(environ, start_response):
"""Go Main Go"""
if "sts" not in environ:
Expand Down
3 changes: 2 additions & 1 deletion htdocs/agclimate/nmp_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pandas as pd
from metpy.units import units
from pyiem.network import Table as NetworkTable
from pyiem.reference import ISO8601
from pyiem.util import convert_value, get_sqlalchemy_conn
from pyiem.webutil import iemapp

Expand Down Expand Up @@ -147,7 +148,7 @@ def use_table(sio):
sid,
nt.sts[sid]["lat"],
nt.sts[sid]["lon"],
row["utc_valid"].strftime("%Y-%m-%dT%H:%M:%SZ"),
row["utc_valid"].strftime(ISO8601),
nt.sts[sid]["elevation"],
do_soil_moisture(row),
p(hr_row["slrkj_tot"] * 1000.0 / 3600.0, 1, 0, 1600),
Expand Down
4 changes: 2 additions & 2 deletions htdocs/cow/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ the parameters are required.</p>
</tr>
<tr><th colspan="3">Time Specification Option 1</th></tr>
<tr>
<td>begints=ISO9660<br />endts=ISO9660</td>
<td>begints=ISO8601<br />endts=ISO8601</td>
<td>Last 4 Hour Period</td>
<td>This start time and end time sets the window to look for NWS Storm Based
Warnings and Local Storm Reports. For the case of warnings, the warning must
Expand Down Expand Up @@ -458,7 +458,7 @@ example, <code>fcster=forecaster10</code></td></tr>
<h4>Resulting JSON Schema.</h4>
<pre>
{"generated_at": "ISO9660",
{"generated_at": "ISO8601",
"params": {dictionary of how API was called},
"stats": {dictionary of generated statistics},
"area_verify%": float # percent of polygon area verified
Expand Down
6 changes: 3 additions & 3 deletions htdocs/geojson/7am.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from zoneinfo import ZoneInfo

from pyiem.exceptions import IncompleteWebRequest
from pyiem.reference import TRACE_VALUE
from pyiem.reference import ISO8601, TRACE_VALUE
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -70,7 +70,7 @@ def run_azos(ts):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down Expand Up @@ -115,7 +115,7 @@ def run(ts, networks):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
5 changes: 3 additions & 2 deletions htdocs/geojson/agclimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json

from pyiem.network import Table as NetworkTable
from pyiem.reference import ISO8601
from pyiem.tracker import loadqc
from pyiem.util import convert_value, drct2text, get_dbconnc, utc
from pyiem.webutil import iemapp
Expand Down Expand Up @@ -69,7 +70,7 @@ def get_inversion_data(cursor, ts):
"id": sid,
"properties": {
"name": nt.sts[sid]["name"],
"valid_utc": ts.strftime("%Y-%m-%dT%H:%M:%SZ"),
"valid_utc": ts.strftime(ISO8601),
"tmpf_15": safe_t(row["tair_15_c_avg"]),
"tmpf_5": safe_t(row["tair_5_c_avg"]),
"tmpf_10": safe_t(row["tair_10_c_avg"]),
Expand Down Expand Up @@ -159,7 +160,7 @@ def get_data(cursor, ts):
"type": "Feature",
"id": sid,
"properties": {
"valid_utc": ts.strftime("%Y-%m-%dT%H:%M:%SZ"),
"valid_utc": ts.strftime(ISO8601),
"plant_water_6_30": compute_plant_water(row),
"encrh_avg": (
f"{safe(row['encrh_avg'], 1)}%"
Expand Down
5 changes: 2 additions & 3 deletions htdocs/geojson/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -44,9 +45,7 @@ def run(network, only_online):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": datetime.datetime.utcnow().strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"generation_time": datetime.datetime.utcnow().strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
3 changes: 2 additions & 1 deletion htdocs/geojson/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand All @@ -21,7 +22,7 @@ def run():
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
9 changes: 4 additions & 5 deletions htdocs/geojson/nexrad_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
from zoneinfo import ZoneInfo

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -57,7 +58,7 @@ def run(ts, fmt):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for i, row in enumerate(cursor):
Expand All @@ -81,9 +82,7 @@ def run(ts, fmt):
"top": row["top"],
"drct": row["drct"],
"sknt": row["sknt"],
"valid": row["utc_valid"].strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"valid": row["utc_valid"].strftime(ISO8601),
},
"geometry": {
"type": "Point",
Expand Down Expand Up @@ -117,7 +116,7 @@ def run(ts, fmt):
row["top"],
row["drct"],
row["sknt"],
row["utc_valid"].strftime("%Y-%m-%dT%H:%M:%SZ"),
row["utc_valid"].strftime(ISO8601),
]
]
)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/geojson/recent_metar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Recent METARs containing some pattern """
import json

from pyiem.reference import TRACE_VALUE
from pyiem.reference import ISO8601, TRACE_VALUE
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_data(q):
"name": row["name"],
"value": trace(row["data"]),
"metar": row["raw"],
"valid": row["utc_valid"].strftime("%Y-%m-%dT%H:%M:%SZ"),
"valid": row["utc_valid"].strftime(ISO8601),
},
"geometry": {
"type": "Point",
Expand Down
9 changes: 5 additions & 4 deletions htdocs/geojson/sbw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
from zoneinfo import ZoneInfo

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape, utc
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand All @@ -16,7 +17,7 @@ def run(ts):
utcnow = utc()
t0 = utcnow + datetime.timedelta(days=7)
else:
utcnow = datetime.datetime.strptime(ts, "%Y-%m-%dT%H:%M:%SZ").replace(
utcnow = datetime.datetime.strptime(ts, ISO8601).replace(
tzinfo=ZoneInfo("UTC")
)
t0 = utcnow
Expand All @@ -40,16 +41,16 @@ def run(ts):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
sid = (
f"{row['wfo']}.{row['phenomena']}.{row['significance']}."
f"{row['eventid']:04.0f}"
)
ets = row["utc_polygon_end"].strftime("%Y-%m-%dT%H:%M:%SZ")
sts = row["utc_polygon_begin"].strftime("%Y-%m-%dT%H:%M:%SZ")
ets = row["utc_polygon_end"].strftime(ISO8601)
sts = row["utc_polygon_begin"].strftime(ISO8601)
sid += "." + sts
res["features"].append(
dict(
Expand Down
7 changes: 4 additions & 3 deletions htdocs/geojson/sps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand All @@ -28,12 +29,12 @@ def run():
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
sts = row["utc_issue"].strftime("%Y-%m-%dT%H:%M:%SZ")
ets = row["utc_expire"].strftime("%Y-%m-%dT%H:%M:%SZ")
sts = row["utc_issue"].strftime(ISO8601)
ets = row["utc_expire"].strftime(ISO8601)
href = f"/api/1/nwstext/{row['product_id']}"
res["features"].append(
dict(
Expand Down
3 changes: 2 additions & 1 deletion htdocs/geojson/usdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json

from pyiem.exceptions import IncompleteWebRequest
from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -51,7 +52,7 @@ def run(ts):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
17 changes: 5 additions & 12 deletions htdocs/geojson/vtec_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

import simplejson as json
from pyiem.exceptions import IncompleteWebRequest
from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client

ISO = "%Y-%m-%dT%H:%M:%SZ"


def run_lsrs(wfo, year, phenomena, significance, etn, sbw):
"""Do great things"""
Expand Down Expand Up @@ -47,17 +46,15 @@ def run_lsrs(wfo, year, phenomena, significance, etn, sbw):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": datetime.datetime.utcnow().strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"generation_time": datetime.datetime.utcnow().strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
res["features"].append(
dict(
type="Feature",
properties=dict(
utc_valid=row["utc_valid"].strftime(ISO),
utc_valid=row["utc_valid"].strftime(ISO8601),
event=row["typetext"],
type=row["type"],
magnitude=row["magnitude"],
Expand Down Expand Up @@ -92,9 +89,7 @@ def run_sbw(wfo, year, phenomena, significance, etn):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": datetime.datetime.utcnow().strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"generation_time": datetime.datetime.utcnow().strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down Expand Up @@ -131,9 +126,7 @@ def run(wfo, year, phenomena, significance, etn):
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": datetime.datetime.utcnow().strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"generation_time": datetime.datetime.utcnow().strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
3 changes: 2 additions & 1 deletion htdocs/geojson/winter_roads.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json

from pyiem.reference import ISO8601
from pyiem.util import get_dbconn, html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand All @@ -28,7 +29,7 @@ def run():
res = {
"type": "FeatureCollection",
"features": [],
"generation_time": utcnow.strftime("%Y-%m-%dT%H:%M:%SZ"),
"generation_time": utcnow.strftime(ISO8601),
"count": cursor.rowcount,
}
for row in cursor:
Expand Down
5 changes: 3 additions & 2 deletions htdocs/json/current.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Current Observation for a station and network"""
import json

from pyiem.reference import ISO8601
from pyiem.util import get_dbconnc, html_escape, utc
from pyiem.webutil import iemapp
from pymemcache.client import Client
Expand Down Expand Up @@ -28,12 +29,12 @@ def run(network, station):
row = cursor.fetchone()
pgconn.close()
data = {}
data["server_gentime"] = utc().strftime("%Y-%m-%dT%H:%M:%SZ")
data["server_gentime"] = utc().strftime(ISO8601)
data["id"] = station
data["network"] = network
ob = data.setdefault("last_ob", {})
ob["local_valid"] = row["localtime"].strftime("%Y-%m-%d %H:%M")
ob["utc_valid"] = row["utctime"].strftime("%Y-%m-%dT%H:%M:00Z")
ob["utc_valid"] = row["utctime"].strftime(ISO8601)
ob["airtemp[F]"] = row["tmpf"]
ob["max_dayairtemp[F]"] = row["max_tmpf"]
ob["min_dayairtemp[F]"] = row["min_tmpf"]
Expand Down
3 changes: 2 additions & 1 deletion htdocs/json/goes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import os

from pyiem.reference import ISO8601
from pyiem.util import html_escape
from pyiem.webutil import iemapp

Expand All @@ -21,7 +22,7 @@ def parse_time(text):
if len(text) == 17:
date = datetime.datetime.strptime(text, "%Y-%m-%dT%H:%MZ")
elif len(text) == 20:
date = datetime.datetime.strptime(text, "%Y-%m-%dT%H:%M:%SZ")
date = datetime.datetime.strptime(text, ISO8601)
else:
date = datetime.datetime.utcnow()
except Exception:
Expand Down
Loading

0 comments on commit 73c57c9

Please sign in to comment.