Skip to content
Snippets Groups Projects
Commit 9beee95e authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-email' into 'dev'

Refactor email

See merge request !177
parents bc144202 89f48916
Branches
Tags
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!177Refactor email
Pipeline #54393 passed
......@@ -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
......@@ -872,8 +895,8 @@ the CaosDB Crawler successfully crawled the data and
"""
domain = get_config_setting("public_host_url")
if get_config_setting("create_crawler_status_records"):
domain = get_config_setting("public_host_url")
text += ("You can checkout the CrawlerRun Record for more information:\n"
f"{domain}/Entity/?P=0L10&query=find%20crawlerrun%20with%20run_id=%27{run_id}%27\n\n")
text += (f"You can download the logfile here:\n{domain}/Shared/" + logfile)
......@@ -1059,6 +1082,10 @@ def crawler_main(crawled_directory_path: str,
ident = CaosDBIdentifiableAdapter()
ident.load_from_yaml_definition(identifiables_definition_file)
crawler.identifiableAdapter = ident
else:
# TODO
# raise ValueError("An identifiable file is needed.")
pass
remove_prefix = _treat_deprecated_prefix(prefix, remove_prefix)
......
......@@ -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