예제 #1
0
 def test_bool_param_false(self):
     """Test for `bool_param` function - case: false values"""
     self.assertFalse(utils.bool_param("0"))
     self.assertFalse(utils.bool_param("no"))
     self.assertFalse(utils.bool_param("N"))
     self.assertFalse(utils.bool_param("false"))
     self.assertFalse(utils.bool_param("Off"))
예제 #2
0
 def test_bool_param_true(self):
     """Test for `bool_param` function - case: true values"""
     self.assertTrue(utils.bool_param("1"))
     self.assertTrue(utils.bool_param("Yes"))
     self.assertTrue(utils.bool_param("y"))
     self.assertTrue(utils.bool_param("True"))
     self.assertTrue(utils.bool_param("ON"))
예제 #3
0
    def get_worker_env(self):
        """Constructs a dictionary of environment variables for worker
        subprocess.
        This way we can ensure that cron-specific settings are identical
        for scheduler and workers.
        """

        # Note: We need to ensure that values stored in env are
        # string or bytestring

        environ = os.environ.copy()
        environ["CRONMAN_JOBS_MODULE"] = str(config("CRONMAN_JOBS_MODULE"))
        environ["CRONMAN_DATA_DIR"] = str(self.data_dir)
        environ["CRONMAN_DEBUG"] = str(
            int(bool_param(config("CRONMAN_DEBUG"), default=False)))
        environ["CRONMAN_NICE_CMD"] = str(config("CRONMAN_NICE_CMD") or "")
        environ["CRONMAN_IONICE_CMD"] = str(config("CRONMAN_IONICE_CMD") or "")
        environ["CRONMAN_CRONITOR_URL"] = str(config("CRONMAN_CRONITOR_URL"))
        environ["CRONMAN_CRONITOR_ENABLED"] = str(
            int(bool_param(config("CRONMAN_CRONITOR_ENABLED"), default=False)))
        environ["CRONMAN_SLACK_ENABLED"] = str(
            int(bool_param(config("CRONMAN_SLACK_ENABLED"), default=False)))
        environ["CRONMAN_SENTRY_ENABLED"] = str(
            int(bool_param(config("CRONMAN_SENTRY_ENABLED"), default=False)))
        environ.update(self.extra_env)
        return environ
예제 #4
0
 def __init__(self, **kwargs):
     self.data_dir = kwargs.get("data_dir", config("CRONMAN_DATA_DIR"))
     self.debug = kwargs.get("debug", bool_param(config("CRONMAN_DEBUG")))
     self.cronitor = Cronitor()
     self.sentry = Sentry()
     self.slack = Slack()
     ensure_dir(self.data_dir)
     self.logger = kwargs.get("logger", logger)
예제 #5
0
 def __init__(self):
     self.logger = logger
     self.enabled = bool_param(config("CRONMAN_SENTRY_ENABLED"))
     self.raven_cmd = app_settings.CRONMAN_RAVEN_CMD
예제 #6
0
 def __init__(self):
     self.logger = logger
     self.enabled = bool_param(config("CRONMAN_CRONITOR_ENABLED"))
     self.url = app_settings.CRONMAN_CRONITOR_URL
예제 #7
0
 def __init__(self):
     self.logger = logger
     self.enabled = bool_param(config("CRONMAN_SLACK_ENABLED"))
     self.url = app_settings.CRONMAN_SLACK_URL
     self.token = app_settings.CRONMAN_SLACK_TOKEN
     self.default_channel = app_settings.CRONMAN_SLACK_DEFAULT_CHANNEL
예제 #8
0
 def test_bool_param_no_conversion(self):
     """Test for `bool_param` function - case: no conversion"""
     self.assertTrue(utils.bool_param(True))
     self.assertFalse(utils.bool_param(False))
예제 #9
0
 def test_bool_param_undefined(self):
     """Test for `bool_param` function - case: undefined values"""
     self.assertIsNone(utils.bool_param(""))
     self.assertIsNone(utils.bool_param(None))
예제 #10
0
 def __init__(self, host_name=None, **kwargs):
     kwargs["logger"] = kwargs.get("logger", logger)
     super(CronRemoteManager, self).__init__(**kwargs)
     self.host_name = host_name or socket.gethostname()
     self.enabled = bool_param(config("CRONMAN_REMOTE_MANAGER_ENABLED"))