Skip to content
Snippets Groups Projects
Commit 4ce14373 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAITN: move code from old crawler

parent bc144202
Branches
Tags
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!177Refactor email
Pipeline #52888 passed with warnings
......@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Better internal handling of identifiable/reference resolving and merging of entities. This also
includes more understandable output for users.
* Better handling of missing imports, with nice messages for users.
* No longer use configuration of advancedtools to set to and from email addresses
### Deprecated ###
......
......@@ -749,9 +749,31 @@ one with the entities that need to be updated and the other with entities to be
def inform_about_pending_changes(pending_changes, run_id, path, inserts=False):
# Sending an Email with a link to a form to authorize updates is
if get_config_setting("send_crawler_notifications"):
filename = OldCrawler.save_form(
[el[3] for el in pending_changes], path, run_id)
OldCrawler.send_mail([el[3] for el in pending_changes], filename)
filename = OldCrawler.save_form([el[3] for el in pending_changes], path, run_id)
text = """Dear Curator,
there where changes that need your authorization. Please check the following
carefully and if the changes are ok, click on the following link:
{url}/Shared/{filename}
{changes}
""".format(url=db.configuration.get_config()["Connection"]["url"],
filename=filename,
changes="\n".join([el[3] for el in pending_changes]))
try:
fro=get_config_setting("sendmail_from_address")
to=get_config_setting("sendmail_to_address")
except KeyError:
logger.error("Server Configuration is missing a setting for "
"sending mails. The administrator should check "
"'from_mail' and 'to_mail'.")
return
send_mail(
from_addr=fro,
to=to,
subject="Crawler Update",
body=text)
for i, el in enumerate(pending_changes):
......@@ -862,6 +884,7 @@ def _notify_about_inserts_and_updates(n_inserts, n_updates, logfile, run_id):
The email contains some basic information and a link to the log and the CrawlerRun Record.
"""
if not get_config_setting("send_crawler_notifications"):
logger.debug("Crawler email notifications are disabled.")
return
if n_inserts == 0 and n_updates == 0:
return
......
......@@ -30,6 +30,13 @@ to decide what tool is used for sending mails (use the upper one if you
want to actually send mails. See ``sendmail`` configuration in the
LinkAhead docs.
You can even supply the name of a custom CSS file that shall be used:
.. code:: ini
[advancedtools]
crawler.customcssfile = theme-research.css
Crawler Status Records
----------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment