From 4ce143736860e71fd59c6506875717197c800510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Tue, 9 Jul 2024 16:44:11 +0200 Subject: [PATCH] MAITN: move code from old crawler --- CHANGELOG.md | 1 + src/caoscrawler/crawl.py | 29 ++++++++++++++++++-- src/doc/getting_started/optionalfeatures.rst | 7 +++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c9160a5..995ad6ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 627e1dc4..dab9fbba 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -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 diff --git a/src/doc/getting_started/optionalfeatures.rst b/src/doc/getting_started/optionalfeatures.rst index d326d7fc..7b776465 100644 --- a/src/doc/getting_started/optionalfeatures.rst +++ b/src/doc/getting_started/optionalfeatures.rst @@ -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 ---------------------- -- GitLab