# Path: simplemonitor/Monitors/monitor.py
# class Monitor:
# class MonitorFail(Monitor):
# class MonitorNull(Monitor):
#     def __init__(
#         self, name: str = "unnamed", config_options: Optional[dict] = None
#     ) -> None:
#     def get_config_option(
#         self,
#         key: str,
#         *,
#         default: Any = None,
#         required: bool = False,
#         required_type: str = "str",
#         allowed_values: Any = None,
#         allow_empty: bool = True,
#         minimum: Optional[Union[int, float]] = None,
#         maximum: Optional[Union[int, float]] = None,
#     ) -> Any:
#     def dependencies(self) -> List[str]:
#     def dependencies(self, dependency_list: List[str]) -> None:
#     def remaining_dependencies(self) -> List[str]:
#     def is_remote(self) -> bool:
#     def run_test(self) -> Union[NoReturn, bool]:
#     def virtual_fail_count(self) -> int:
#     def test_success(self) -> bool:
#     def first_failure(self) -> bool:
#     def state(self) -> MonitorState:
#     def get_result(self) -> str:
#     def reset_dependencies(self) -> None:
#     def dependency_succeeded(self, dependency: str) -> None:
#     def log_result(self, name: str, logger: Any) -> None:
#     def get_params(self) -> Tuple:
#     def set_mon_refs(self, mmm: Any) -> None:
#     def minimum_gap(self) -> int:
#     def minimum_gap(self, gap: int) -> None:
#     def describe(self) -> str:
#     def is_windows(allow_cygwin: bool = True) -> bool:
#     def _add_unavailable_seconds(self) -> None:
#     def record_fail(self, message: str = "") -> bool:
#     def record_success(self, message: str = "") -> bool:
#     def record_skip(self, which_dep: Optional[str]) -> bool:
#     def uptime(self) -> Optional[datetime.timedelta]:
#     def skipped(self) -> bool:
#     def get_success_count(self) -> int:
#     def all_better_now(self) -> bool:
#     def availability(self) -> float:
#     def first_failure_time(self) -> Optional[arrow.Arrow]:
#     def notify(self) -> bool:
#     def notify(self, value: bool) -> None:
#     def urgent(self) -> bool:
#     def urgent(self, value: Union[bool, int]) -> None:
#     def was_skipped(self) -> bool:
#     def should_run(self) -> bool:
#     def last_virtual_fail_count(self) -> int:
#     def attempt_recover(self) -> None:
#     def run_recovered(self) -> None:
#     def post_config_setup(self) -> None:
#     def __getstate__(self) -> dict:
#     def __setstate__(self, state: dict) -> None:
#     def _set_monitor_logger(self) -> None:
#     def to_python_dict(self) -> dict:
#     def from_python_dict(
#         cls: Any, load_dict: dict
#     ) -> "Monitor":  # can't return Monitor type as flake8 gets cross
#     def get_downtime(self) -> UpDownTime:
#     def get_wasdowntime(self) -> UpDownTime:
#     def get_uptime(self) -> UpDownTime:
#     def state_dict(self) -> dict:
#     def __str__(self) -> str:
#     def __init__(self, name: str, config_options: dict):
#     def run_test(self) -> bool:
#     def describe(self) -> str:
#     def get_params(self) -> Tuple:
#     def run_test(self) -> bool:
#     def get_params(self) -> Tuple:


import fnmatch
import os
import platform
import re
import subprocess
import time
import psutil
    import pydbus
from typing import Any, List, Optional, Tuple, cast
from .monitor import Monitor, register
            self._want_return_code = 1

    def run_test(self) -> bool:
        try:
            result = subprocess.run(
                ["service", self.service_name, "status"],
                check=False,
                stderr=subprocess.PIPE,
                stdout=subprocess.PIPE,
            )  # nosec
            returncode = result.returncode
        except subprocess.SubprocessError as exception:
            return self.record_fail(
                "Failed to run 'service {} status: {}".format(
                    self.service_name, exception
                )
            )
        if returncode == self._want_return_code:
            return self.record_success()
        return self.record_fail(
            "Got exit code {}, wanted {}".format(returncode, self._want_return_code)
        )

    def get_params(self) -> Tuple:
        return (self.service_name, self.want_state)

    def describe(self) -> str:
        return "Checking service {} is {}".format(self.service_name, self.want_state)



# Path: simplemonitor/Monitors/monitor.py
# class Monitor:
# class MonitorFail(Monitor):
# class MonitorNull(Monitor):
#     def __init__(
#         self, name: str = "unnamed", config_options: Optional[dict] = None
#     ) -> None:
#     def get_config_option(
#         self,
#         key: str,
#         *,
#         default: Any = None,
#         required: bool = False,
#         required_type: str = "str",
#         allowed_values: Any = None,
#         allow_empty: bool = True,
#         minimum: Optional[Union[int, float]] = None,
#         maximum: Optional[Union[int, float]] = None,
#     ) -> Any:
#     def dependencies(self) -> List[str]:
#     def dependencies(self, dependency_list: List[str]) -> None:
#     def remaining_dependencies(self) -> List[str]:
#     def is_remote(self) -> bool:
#     def run_test(self) -> Union[NoReturn, bool]:
#     def virtual_fail_count(self) -> int:
#     def test_success(self) -> bool:
#     def first_failure(self) -> bool:
#     def state(self) -> MonitorState:
#     def get_result(self) -> str:
#     def reset_dependencies(self) -> None:
#     def dependency_succeeded(self, dependency: str) -> None:
#     def log_result(self, name: str, logger: Any) -> None:
#     def get_params(self) -> Tuple:
#     def set_mon_refs(self, mmm: Any) -> None:
#     def minimum_gap(self) -> int:
#     def minimum_gap(self, gap: int) -> None:
#     def describe(self) -> str:
#     def is_windows(allow_cygwin: bool = True) -> bool:
#     def _add_unavailable_seconds(self) -> None:
#     def record_fail(self, message: str = "") -> bool:
#     def record_success(self, message: str = "") -> bool:
#     def record_skip(self, which_dep: Optional[str]) -> bool:
#     def uptime(self) -> Optional[datetime.timedelta]:
#     def skipped(self) -> bool:
#     def get_success_count(self) -> int:
#     def all_better_now(self) -> bool:
#     def availability(self) -> float:
#     def first_failure_time(self) -> Optional[arrow.Arrow]:
#     def notify(self) -> bool:
#     def notify(self, value: bool) -> None:
#     def urgent(self) -> bool:
#     def urgent(self, value: Union[bool, int]) -> None:
#     def was_skipped(self) -> bool:
#     def should_run(self) -> bool:
#     def last_virtual_fail_count(self) -> int:
#     def attempt_recover(self) -> None:
#     def run_recovered(self) -> None:
#     def post_config_setup(self) -> None:
#     def __getstate__(self) -> dict:
#     def __setstate__(self, state: dict) -> None:
#     def _set_monitor_logger(self) -> None:
#     def to_python_dict(self) -> dict:
#     def from_python_dict(
#         cls: Any, load_dict: dict
#     ) -> "Monitor":  # can't return Monitor type as flake8 gets cross
#     def get_downtime(self) -> UpDownTime:
#     def get_wasdowntime(self) -> UpDownTime:
#     def get_uptime(self) -> UpDownTime:
#     def state_dict(self) -> dict:
#     def __str__(self) -> str:
#     def __init__(self, name: str, config_options: dict):
#     def run_test(self) -> bool:
#     def describe(self) -> str:
#     def get_params(self) -> Tuple:
#     def run_test(self) -> bool:
#     def get_params(self) -> Tuple:


# Path: simplemonitor/Monitors/service.py
import fnmatch
import os
import platform
import re
import subprocess
import time
import psutil
    import pydbus
from typing import Any, List, Optional, Tuple, cast
from .monitor import Monitor, register

            self._want_return_code = 1

    def run_test(self) -> bool:
        try:
            result = subprocess.run(
                ["service", self.service_name, "status"],
                check=False,
                stderr=subprocess.PIPE,
                stdout=subprocess.PIPE,
            )  # nosec
            returncode = result.returncode
        except subprocess.SubprocessError as exception:
            return self.record_fail(
                "Failed to run 'service {} status: {}".format(
                    self.service_name, exception
                )
            )
        if returncode == self._want_return_code:
            return self.record_success()
        return self.record_fail(
            "Got exit code {}, wanted {}".format(returncode, self._want_return_code)
        )

    def get_params(self) -> Tuple:
        return (self.service_name, self.want_state)

    def describe(self) -> str:
        return "Checking service {} is {}".format(self.service_name, self.want_state)



@register