Skip to content

Commit

Permalink
Sort imports (#46)
Browse files Browse the repository at this point in the history
Command:
 * isort --profile=black .

Note:
 * this also addresses a couple of pylint issues

Additionally:
 * add isort configuration section to the pyproject.toml file
  • Loading branch information
jpoliv authored Apr 4, 2024
1 parent 9c90b7c commit 014c7a4
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 47 deletions.
32 changes: 17 additions & 15 deletions anycast_healthchecker/healthchecker.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# pylint: disable=too-few-public-methods

"""A library which provides the HealthChecker class."""
from configparser import NoOptionError
import logging
import os
import sys
import logging
from queue import Queue
import threading
from configparser import NoOptionError
from queue import Queue

from prometheus_client import CollectorRegistry, Counter, Gauge

from anycast_healthchecker import PROGRAM_NAME, METRIC_PREFIX
from anycast_healthchecker import METRIC_PREFIX, PROGRAM_NAME
from anycast_healthchecker.servicecheck import ServiceCheck
from anycast_healthchecker.utils import (SERVICE_OPTIONS_TYPE,
get_ip_prefixes_from_bird,
get_ip_prefixes_from_config,
reconfigure_bird,
write_temp_bird_conf,
archive_bird_conf,
ServiceCheckDiedError,
run_custom_bird_reconfigure,
MainExporter)

from prometheus_client import Gauge, CollectorRegistry, Counter
from anycast_healthchecker.utils import (
SERVICE_OPTIONS_TYPE,
MainExporter,
ServiceCheckDiedError,
archive_bird_conf,
get_ip_prefixes_from_bird,
get_ip_prefixes_from_config,
reconfigure_bird,
run_custom_bird_reconfigure,
write_temp_bird_conf,
)


class HealthChecker:
Expand Down
23 changes: 16 additions & 7 deletions anycast_healthchecker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@
-v, --version show version
-h, --help show this screen
"""
from functools import partial
import socket
import signal
import socket
import sys
from functools import partial

from docopt import docopt

from anycast_healthchecker import (DEFAULT_OPTIONS, PROGRAM_NAME, __version__,
healthchecker)
from anycast_healthchecker.utils import (load_configuration, shutdown,
ip_prefixes_sanity_check,
update_pidfile, setup_logger)
from anycast_healthchecker import (
DEFAULT_OPTIONS,
PROGRAM_NAME,
__version__,
healthchecker,
)
from anycast_healthchecker.utils import (
ip_prefixes_sanity_check,
load_configuration,
setup_logger,
shutdown,
update_pidfile,
)


def main():
Expand Down
15 changes: 9 additions & 6 deletions anycast_healthchecker/servicecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

"""A library which provides the ServiceCheck class."""

import ipaddress
import logging
import random
import shlex
import subprocess
import time
import logging
import traceback
from threading import Thread
import ipaddress
import random
import shlex

from anycast_healthchecker import PROGRAM_NAME
from anycast_healthchecker.utils import (AddOperation, DeleteOperation,
ServiceCheckDiedError)
from anycast_healthchecker.utils import (
AddOperation,
DeleteOperation,
ServiceCheckDiedError,
)


class ServiceCheck(Thread):
Expand Down
36 changes: 19 additions & 17 deletions anycast_healthchecker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@
# pylint: disable=too-few-public-methods
# pylint: disable=too-many-lines
"""Provide functions and classes that are used within anycast_healthchecker."""
from collections import Counter
import re
import os
import signal
import sys
import subprocess
import logging
import logging.handlers
from threading import Thread
import time
import datetime
import configparser
import datetime
import glob
import ipaddress
import logging
import logging.handlers
import os
import re
import shlex
import shutil
import ipaddress
import signal
import subprocess
import sys
import time
from collections import Counter
from threading import Thread

from prometheus_client import CollectorRegistry, Gauge, Info, write_to_textfile
from pythonjsonlogger import jsonlogger

from anycast_healthchecker import DEFAULT_OPTIONS, PROGRAM_NAME, __version__, METRIC_PREFIX

from prometheus_client import Gauge, CollectorRegistry, write_to_textfile, Info


from anycast_healthchecker import (
DEFAULT_OPTIONS,
METRIC_PREFIX,
PROGRAM_NAME,
__version__,
)

SERVICE_OPTIONS_TYPE = {
'check_cmd': 'get',
Expand Down
5 changes: 3 additions & 2 deletions contrib/nagios/check_anycast_healthchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
Options:
-v report what it does
"""
import os
import sys
import configparser
import glob
import os
import subprocess
import sys

from docopt import docopt


Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ readme = {file = ["README.rst"]}
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[tool.isort]
# https://pycqa.github.io/isort/docs/configuration/profiles.html
profile = "black"

0 comments on commit 014c7a4

Please sign in to comment.