Exemple #1
0
def convert_option(key, val):
    if key == "numprocesses":
        return int(val)
    elif key == "warmup_delay":
        return float(val)
    elif key == "working_dir":
        return val
    elif key == "uid":
        return val
    elif key == "gid":
        return val
    elif key == "send_hup":
        return util.to_bool(val)
    elif key == "shell":
        return util.to_bool(val)
    elif key == "env":
        return util.parse_env(val)
    elif key == "cmd":
        return val
    elif key == "flapping_attempts":
        return int(val)
    elif key == "flapping_window":
        return float(val)
    elif key == "retry_in":
        return float(val)
    elif key == "max_retry":
        return int(val)
    elif key == "graceful_timeout":
        return float(val)
    elif key == 'max_age':
        return int(val)
    elif key == 'max_age_variance':
        return int(val)

    raise ArgumentError("unknown key %r" % key)
Exemple #2
0
 def _convert_opt(self, key, val):
     if key == "numprocesses":
         return int(val)
     elif key == "warmup_delay":
         return float(val)
     elif key == "working_dir":
         return val
     elif key == "uid":
         return val
     elif key == "gid":
         return val
     elif key == "send_hup":
         return util.to_bool(val)
     elif key == "shell":
         return util.to_bool(val)
     elif key == "env":
         return util.parse_env(val)
     elif key == "cmd":
         return  val
     elif key == "times":
         return int(val)
     elif key == "within":
         return float(val)
     elif key == "retry_in":
         return float(val)
     elif key == "max_retry":
         return int(val)
     elif key == "graceful_timeout":
         return float(val)
     raise ArgumentError("unkown key %r" % key)
Exemple #3
0
def convert_option(key, val):
    if key == "numprocesses":
        return int(val)
    elif key == "warmup_delay":
        return float(val)
    elif key == "working_dir":
        return val
    elif key == "uid":
        return val
    elif key == "gid":
        return val
    elif key == "send_hup":
        return util.to_bool(val)
    elif key == "shell":
        return util.to_bool(val)
    elif key == "env":
        return util.parse_env(val)
    elif key == "cmd":
        return val
    elif key == "flapping_attempts":
        return int(val)
    elif key == "flapping_window":
        return float(val)
    elif key == "retry_in":
        return float(val)
    elif key == "max_retry":
        return int(val)
    elif key == "graceful_timeout":
        return float(val)
    raise ArgumentError("unkown key %r" % key)
Exemple #4
0
    def set_opt(self, key, val):
        """ set a show option

        This function set the show options. unknown keys are ignored.
        This function return an action number:

        - 0: trigger the process management
        - 1: trigger a graceful reload of the flies;
        """

        action = 0
        if key == "numflies":
            self.numflies = int(val)
        elif key == "warmup_delay":
            self.warmup_delay = float(val)
        elif key == "working_dir":
            self.working_dir = val
            action = 1
        elif key == "uid":
            self.uid = util.to_uid(val)
            action = 1
        elif key == "gid":
            self.gid = util.to_gid(val)
            action = 1
        elif key == "send_hup":
            self.send_hup = util.to_bool(val)
        elif key == "shell":
            self.shell = util.to_bool(val)
            action = 1
        elif key == "env":
            self.env = util.parse_env(val)
            action = 1
        elif key == "cmd":
            self.cmd = val
            action = 1
        elif key == "times":
            self.times = int(val)
            action = -1
        elif key == "within":
             self.within = float(val)
        elif key == "retry_in":
            self.retry_in = float(val)
        elif key == "max_retry":
            self.max_retry = int(val)
        elif key == "graceful_timeout":
            self.graceful_timeout = float(val)
            action = -1
        self.send_msg("updated", {"time": time.time()})
        return action
Exemple #5
0
    def set_opt(self, key, val):
        """ set a show option

        This function set the show options. unknown keys are ignored.
        This function return an action number:

        - 0: trigger the process management
        - 1: trigger a graceful reload of the flies;
        """

        action = 0
        if key == "num_flies":
            self.num_flies = int(val)
        elif key == "warmup_delay":
            self.warmup_delay = float(val)
        elif key == "working_dir":
            self.working_dir = val
            action = 1
        elif key == "uid":
            self.uid = util.to_uid(val)
            action = 1
        elif key == "gid":
            self.gid = util.to_gid(val)
            action = 1
        elif key == "send_hup":
            self.send_hup = util.to_bool(val)
        elif key == "shell":
            self.shell = util.to_bool(val)
            action = 1
        elif key == "env":
            self.env = util.parse_env(val)
            action = 1
        elif key == "cmd":
            self.cmd = val
            action = 1
        elif key == "times":
            self.flapping.times = int(val)
            action = -1
        elif key == "within":
            self.flapping.within = float(val)
        elif key == "retry_in":
            self.flapping.retry_in = float(val)
        elif key == "max_retry":
            self.flapping.max_retry = int(val)
        return action
Exemple #6
0
 def load_from_config(cls, config):
     if 'env' in config:
         config['env'] = parse_env(config['env'])
     return cls(name=config.pop('name'), cmd=config.pop('cmd'), **config)
Exemple #7
0
 def test_parse_env(self):
     env = "test=1,booo=2"
     parsed = parse_env(env)
     self.assertEqual(env_to_str(parsed), env)
Exemple #8
0
 def load_from_config(cls, config):
     if 'env' in config:
         config['env'] = parse_env(config['env'])
     return cls(name=config.pop('name'), cmd=config.pop('cmd'), **config)
Exemple #9
0
 def test_parse_env(self):
     env = 'test=1,booo=2'
     parsed = parse_env(env)
     self.assertEqual(parsed, {'test': '1', 'booo': '2'})
     self.assertEqual(env_to_str(parsed), env)
Exemple #10
0
 def test_parse_env(self):
     env = 'test=1,booo=2'
     parsed = parse_env(env)
     self.assertEqual(env_to_str(parsed), env)
Exemple #11
0
 def test_parse_env(self):
     env = 'test=1,booo=2'
     parsed = parse_env(env)
     self.assertEqual(parsed, {'test': '1', 'booo': '2'})
     self.assertEqual(env_to_str(parsed), env)