Compare commits
2 commits
0ecc4577c2
...
d99f514dfc
Author | SHA1 | Date | |
---|---|---|---|
d99f514dfc | |||
8d70c82d99 |
1 changed files with 16 additions and 11 deletions
27
scl.py
27
scl.py
|
@ -246,17 +246,22 @@ def do_initial_post(
|
||||||
map_media_post = None
|
map_media_post = None
|
||||||
hashtag_string = get_hashtag_string(event)
|
hashtag_string = get_hashtag_string(event)
|
||||||
|
|
||||||
|
est_restoration_post_text = str()
|
||||||
|
if estimated_restoration_time > datetime.now():
|
||||||
|
est_restoration_post_text = "\nEst. Restoration: {}\n".format(
|
||||||
|
estimated_restoration_time.strftime(post_datetime_format)
|
||||||
|
)
|
||||||
|
|
||||||
post_text = """Seattle City Light is reporting a {} outage in {}.
|
post_text = """Seattle City Light is reporting a {} outage in {}.
|
||||||
|
|
||||||
Start Date: {}
|
Start Date: {}{}
|
||||||
Est. Restoration: {}
|
|
||||||
Cause: {}
|
Cause: {}
|
||||||
|
|
||||||
{}""".format(
|
{}""".format(
|
||||||
event_class["size"].lower(),
|
event_class["size"].lower(),
|
||||||
area_text,
|
area_text,
|
||||||
start_time.strftime(post_datetime_format),
|
start_time.strftime(post_datetime_format),
|
||||||
estimated_restoration_time.strftime(post_datetime_format),
|
est_restoration_post_text,
|
||||||
event["cause"],
|
event["cause"],
|
||||||
hashtag_string,
|
hashtag_string,
|
||||||
)
|
)
|
||||||
|
@ -333,12 +338,14 @@ with Session(engine) as session:
|
||||||
updated_entries = []
|
updated_entries = []
|
||||||
if estimated_restoration_time != existing_record.estimated_restoration_time:
|
if estimated_restoration_time != existing_record.estimated_restoration_time:
|
||||||
existing_record.estimated_restoration_time = estimated_restoration_time
|
existing_record.estimated_restoration_time = estimated_restoration_time
|
||||||
updated_properties.append("estimated restoration")
|
if estimated_restoration_time > datetime.now():
|
||||||
updated_entries.append(
|
# New estimated restoration time is in the future, so likely to be a real time
|
||||||
"Est. Restoration: {}".format(
|
updated_properties.append("estimated restoration")
|
||||||
estimated_restoration_time.strftime(post_datetime_format)
|
updated_entries.append(
|
||||||
|
"Est. Restoration: {}".format(
|
||||||
|
estimated_restoration_time.strftime(post_datetime_format)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
if event["cause"] != existing_record.cause:
|
if event["cause"] != existing_record.cause:
|
||||||
existing_record.cause = event["cause"]
|
existing_record.cause = event["cause"]
|
||||||
updated_properties.append("cause")
|
updated_properties.append("cause")
|
||||||
|
@ -453,9 +460,7 @@ with Session(engine) as session:
|
||||||
if active_outage.most_recent_post_id:
|
if active_outage.most_recent_post_id:
|
||||||
try:
|
try:
|
||||||
post_result = mastodon_client.status_post(
|
post_result = mastodon_client.status_post(
|
||||||
status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(
|
status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage",
|
||||||
active_outage.outage_user_id
|
|
||||||
),
|
|
||||||
in_reply_to_id=active_outage.most_recent_post_id,
|
in_reply_to_id=active_outage.most_recent_post_id,
|
||||||
visibility="public",
|
visibility="public",
|
||||||
language="en",
|
language="en",
|
||||||
|
|
Loading…
Reference in a new issue