Skip to content

Commit

Permalink
suggestions and loglevel tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
half-duplex committed Jun 3, 2022
1 parent de7a3b4 commit 0ff6bd3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sopel/modules/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def setup(bot: Sopel):

if bot.settings.safety.default_mode is None:
bot.settings.safety.default_mode = "on"
# migrate from enabled_by_default to default_mode. remove in v8.1 or v9
# migrate from enabled_by_default to default_mode. TODO: remove in v8.1 or v9
if not bot.settings.safety.enabled_by_default:
bot.settings.safety.default_mode = "off"
LOGGER.info(
LOGGER.warning(
"config: enabled_by_default is deprecated, please use default_mode=off",
)

Expand All @@ -106,7 +106,7 @@ def setup(bot: Sopel):
for item in bot.settings.safety.known_good:
known_good.append(re.compile(item, re.I))

# clean up old files
# clean up old files. TODO: remove in v8.1 or 9
old_file = os.path.join(bot.settings.homedir, "malwaredomains.txt")
if os.path.exists(old_file) and os.path.isfile(old_file):
LOGGER.info('Removing old malwaredomains file from %s', old_file)
Expand Down Expand Up @@ -143,7 +143,7 @@ def download_domain_list(bot: Sopel, path: str) -> bool:
if old_etag:
r = requests.head(url)
if r.headers["ETag"] == old_etag and os.path.isfile(path):
LOGGER.debug("Unsafe domain list unchanged, skipping")
LOGGER.info("Unsafe domain list unchanged, skipping")
return False

r = requests.get(url, stream=True)
Expand All @@ -154,7 +154,7 @@ def download_domain_list(bot: Sopel, path: str) -> bool:
f.write(data)
except Exception:
# don't bother handling, we'll try again tomorrow
LOGGER.warning("Unsafe domain list download failed, using cache")
LOGGER.warning("Unsafe domain list download failed; using cache")
return False
# .new+move so we don't clobber it if the download fails in the middle
os.rename(path + ".new", path)
Expand Down Expand Up @@ -457,7 +457,7 @@ def _clean_cache(bot: Sopel):
update_local_cache(bot)

if bot.memory['safety_cache_lock'].acquire(False):
LOGGER.info('Starting safety cache cleanup...')
LOGGER.debug('Starting safety cache cleanup...')
cutoff = datetime.now(timezone.utc) - timedelta(days=7)
try:
# clean up by age first
Expand All @@ -481,7 +481,7 @@ def _clean_cache(bot: Sopel):
# No matter what errors happen (or not), release the lock
bot.memory['safety_cache_lock'].release()

LOGGER.info('Safety cache cleanup finished.')
LOGGER.debug('Safety cache cleanup finished.')
else:
LOGGER.info(
'Skipping safety cache cleanup: Cache is locked, '
Expand Down

0 comments on commit 0ff6bd3

Please sign in to comment.