From 7045a4b9ed36ce898eb9ab9d429dda6c1d70cff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Sun, 25 Jun 2023 21:14:22 +0200 Subject: [PATCH 1/4] Improve debugging for clean command --- src/pyevents/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pyevents/cli.py b/src/pyevents/cli.py index 36ec61e..8e6244f 100644 --- a/src/pyevents/cli.py +++ b/src/pyevents/cli.py @@ -38,22 +38,25 @@ def cli(): def clean_after(cutoff_datetime, destination_dirname, verbose): structlog.configure( wrapper_class=structlog.make_filtering_bound_logger( - logging.INFO if verbose else logging.WARNING + logging.DEBUG if verbose else logging.INFO ), ) cutoff_date = cutoff_datetime.date() + logging.debug("Cutoff date set", cutoff_date=cutoff_date) for event_path in Path(destination_dirname).glob("**/*.json"): - logger.debug("Event file found", event_path=event_path) event_date = dt.datetime.strptime( event_path.name.split("_")[0], "%Y-%m-%d" ).date() + logger.debug("Event file found", event_path=event_path, event_date=event_date) if event_date > cutoff_date: logger.info( "Deleting event file", event_path=event_path, event_date=event_date ) event_path.unlink() + else: + logger.info("No event files deleted") @cli.command() From 21f765513a134f01cc9f52bf7b04603115ebe71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Sun, 25 Jun 2023 21:15:00 +0200 Subject: [PATCH 2/4] Add more debugging information on clean task --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 128baf7..d502f84 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,7 @@ git_committer_name := "Python EspaƱa" git_committer_email := "contacto@es.python.org" clean-future: - pyevents clean-after -l $(date -I) + pyevents clean-after -v -l $(date -I) fetch-upcoming: pyevents fetch-upcoming -c communities.toml From 345b8bf8847d09a3afc3739bf4f96b06c7c1ec4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Sun, 25 Jun 2023 21:28:42 +0200 Subject: [PATCH 3/4] Improve debugging for fetch command --- src/pyevents/cli.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pyevents/cli.py b/src/pyevents/cli.py index 8e6244f..653e12b 100644 --- a/src/pyevents/cli.py +++ b/src/pyevents/cli.py @@ -68,7 +68,7 @@ def clean_after(cutoff_datetime, destination_dirname, verbose): def fetch_upcoming(communities_path, destination_dirname, verbose): structlog.configure( wrapper_class=structlog.make_filtering_bound_logger( - logging.INFO if verbose else logging.WARNING + logging.DEBUG if verbose else logging.INFO ), ) @@ -76,19 +76,26 @@ def fetch_upcoming(communities_path, destination_dirname, verbose): communities_data = tomllib.load(f) communities = communities_data["communities"] - upcoming_events = collect_upcoming_events(communities) - if not (destination_dir := Path(destination_dirname)).is_dir(): destination_dir.mkdir() + upcoming_events = collect_upcoming_events(communities) + for community_slug, events in upcoming_events.items(): if not (community_dir := (destination_dir / community_slug)).is_dir(): community_dir.mkdir() for event_data in events: event = event_data["data"]["event"] + logger.debug("Saving new event", event_title=event["title"]) with open(community_dir / f"{event_name_from_data(event)}.json", "w") as fh: json.dump(event, fh, indent=2) + else: + logger.debug( + "No new events found for this community", community_slug=community_slug + ) + else: + logger.info("No new events found") if __name__ == "__main__": From 69249975779f9004485441b5f9f7c42ae3a39bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Sun, 25 Jun 2023 21:29:03 +0200 Subject: [PATCH 4/4] Add more debugging information on fetch task --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index d502f84..030befc 100644 --- a/justfile +++ b/justfile @@ -6,7 +6,7 @@ clean-future: pyevents clean-after -v -l $(date -I) fetch-upcoming: - pyevents fetch-upcoming -c communities.toml + pyevents fetch-upcoming -v -c communities.toml commit-events: git fetch