Compare commits
2 commits
0ea85ff307
...
d47f444ba7
| Author | SHA1 | Date | |
|---|---|---|---|
| d47f444ba7 | |||
| ffa76d7822 |
2 changed files with 15 additions and 5 deletions
|
|
@ -46,9 +46,13 @@ def configure_and_validate_mailer(config, logger):
|
|||
config.get(ConfigParameter.SMTP_LOGIN),
|
||||
config.get(ConfigParameter.SMTP_PASSWORD),
|
||||
)
|
||||
mailer.configure_destination(config.get(ConfigParameter.SITE_ADMIN_EMAIL))
|
||||
if not mailer.check():
|
||||
logger.error("Email configuration not working")
|
||||
mailer.configure_destination(config.get(ConfigParameter.SITE_ADMIN_EMAIL))
|
||||
try:
|
||||
if not mailer.check():
|
||||
logger.error("Email configuration not working")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
logging.error("Failed to check email: %s", e)
|
||||
sys.exit(1)
|
||||
return mailer
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import markdown
|
||||
import PyRSS2Gen
|
||||
|
||||
from stacosys.db import dao
|
||||
|
||||
RFC_822_FORMAT = '%a, %d %b %Y %H:%M:%S +0000'
|
||||
|
||||
|
||||
class Rss:
|
||||
def __init__(self) -> None:
|
||||
|
|
@ -40,7 +42,7 @@ class Rss:
|
|||
link=item_link,
|
||||
description=markdownizer.convert(row.content),
|
||||
guid=PyRSS2Gen.Guid(f"{item_link}{row.id}"),
|
||||
pubDate=row.published,
|
||||
pubDate=self._to_rfc822(row.published)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -54,3 +56,7 @@ class Rss:
|
|||
)
|
||||
with open(self._rss_file, "w", encoding="utf-8") as outfile:
|
||||
rss.write_xml(outfile, encoding="utf-8")
|
||||
|
||||
def _to_rfc822(self, dt):
|
||||
return dt.replace(tzinfo=timezone.utc) \
|
||||
.strftime('%a, %d %b %Y %H:%M:%S %z')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue