Skip to content

Commit

Permalink
Use warnings.warn instead of self.log.warning to help avoid duplications
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Jun 8, 2023
1 parent 5b91309 commit 67087e8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions systemdspawner/systemdspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pwd
import sys
import warnings

from jupyterhub.spawner import Spawner
from jupyterhub.utils import random_port
Expand Down Expand Up @@ -157,16 +158,14 @@ def __init__(self, *args, **kwargs):

systemd_version = systemd.get_systemd_version()
if systemd_version is None:
self.log.warning(
"Failed to parse systemd version from 'systemctl --version'"
)
warnings.warn("Failed to parse systemd version from 'systemctl --version'")
elif systemd_version < SYSTEMD_REQUIRED_VERSION:
self.log.critical(
f"systemd version {SYSTEMD_REQUIRED_VERSION} or higher is required, version {systemd_version} is used"
)
sys.exit(1)
elif systemd_version < SYSTEMD_LOWEST_RECOMMENDED_VERSION:
self.log.warning(
warnings.warn(
f"systemd version {SYSTEMD_LOWEST_RECOMMENDED_VERSION} or higher is recommended, version {systemd_version} is used"
)

Expand Down

0 comments on commit 67087e8

Please sign in to comment.