mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
improve log messages
This commit is contained in:
@@ -65,7 +65,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
self.load_config()
|
self.load_config()
|
||||||
self.load_ads()
|
self.load_ads()
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
LOG.info("No configuration errors found.")
|
LOG.info("DONE: No configuration errors found.")
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
case "publish":
|
case "publish":
|
||||||
self.configure_file_logging()
|
self.configure_file_logging()
|
||||||
@@ -76,7 +76,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
self.publish_ads(ads)
|
self.publish_ads(ads)
|
||||||
else:
|
else:
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
LOG.info("No ads to (re-)publish found.")
|
LOG.info("DONE: No new/outdated ads found.")
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
@@ -157,14 +157,14 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
LOG.info("App version: %s", self.get_version())
|
LOG.info("App version: %s", self.get_version())
|
||||||
|
|
||||||
def load_ads(self, *, exclude_inactive = True, exclude_undue = True) -> Iterable[dict[str, Any]]:
|
def load_ads(self, *, exclude_inactive = True, exclude_undue = True) -> Iterable[dict[str, Any]]:
|
||||||
LOG.info("Searching for ad files...")
|
LOG.info("Searching for ad config files...")
|
||||||
|
|
||||||
ad_files = set()
|
ad_files = set()
|
||||||
data_root_dir = os.path.dirname(self.config_file_path)
|
data_root_dir = os.path.dirname(self.config_file_path)
|
||||||
for file_pattern in self.config["ad_files"]:
|
for file_pattern in self.config["ad_files"]:
|
||||||
for ad_file in glob.glob(file_pattern, root_dir = data_root_dir, recursive = True):
|
for ad_file in glob.glob(file_pattern, root_dir = data_root_dir, recursive = True):
|
||||||
ad_files.add(abspath(ad_file, relative_to = data_root_dir))
|
ad_files.add(abspath(ad_file, relative_to = data_root_dir))
|
||||||
LOG.info(" -> found %s", pluralize("ad file", ad_files))
|
LOG.info(" -> found %s", pluralize("ad config file", ad_files))
|
||||||
if not ad_files:
|
if not ad_files:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
ads = []
|
ads = []
|
||||||
for ad_file in sorted(ad_files):
|
for ad_file in sorted(ad_files):
|
||||||
|
|
||||||
ad_cfg_orig = utils.load_dict(ad_file, "ad file")
|
ad_cfg_orig = utils.load_dict(ad_file, "ad")
|
||||||
ad_cfg = copy.deepcopy(ad_cfg_orig)
|
ad_cfg = copy.deepcopy(ad_cfg_orig)
|
||||||
apply_defaults(ad_cfg, self.config["ad_defaults"], ignore = lambda k, _: k == "description", override = lambda _, v: v == "")
|
apply_defaults(ad_cfg, self.config["ad_defaults"], ignore = lambda k, _: k == "description", override = lambda _, v: v == "")
|
||||||
apply_defaults(ad_cfg, ad_fields)
|
apply_defaults(ad_cfg, ad_fields)
|
||||||
@@ -195,7 +195,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
if last_updated_on:
|
if last_updated_on:
|
||||||
ad_age = datetime.utcnow() - last_updated_on
|
ad_age = datetime.utcnow() - last_updated_on
|
||||||
if ad_age.days <= ad_cfg["republication_interval"]:
|
if ad_age.days <= ad_cfg["republication_interval"]:
|
||||||
LOG.info(" -> skipping. last published %d days ago. republication is only required every %s days",
|
LOG.info(" -> SKIPPED: ad was last published %d days ago. republication is only required every %s days",
|
||||||
ad_age.days,
|
ad_age.days,
|
||||||
ad_cfg["republication_interval"]
|
ad_cfg["republication_interval"]
|
||||||
)
|
)
|
||||||
@@ -249,7 +249,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
ad_cfg_orig
|
ad_cfg_orig
|
||||||
))
|
))
|
||||||
|
|
||||||
LOG.info(" -> loaded %s", pluralize("ad", ads))
|
LOG.info("Loaded %s", pluralize("ad", ads))
|
||||||
return ads
|
return ads
|
||||||
|
|
||||||
def load_config(self) -> None:
|
def load_config(self) -> None:
|
||||||
@@ -341,7 +341,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
pause(3000, 5000)
|
pause(3000, 5000)
|
||||||
|
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
LOG.info("(Re-)published %s", pluralize("ad", count))
|
LOG.info("DONE: (Re-)published %s", pluralize("ad", count))
|
||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
|
|
||||||
def publish_ad(self, ad_file, ad_cfg: dict[str, Any], ad_cfg_orig: dict[str, Any]) -> None:
|
def publish_ad(self, ad_file, ad_cfg: dict[str, Any], ad_cfg_orig: dict[str, Any]) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user