Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(14)  |  Call(10)  |  Derive(0)  |  Import(4)

        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 == "stop_signal":
        return util.to_signum(val)
    elif key == "stop_children":
        return util.to_bool(val)
    elif key == "shell":
        return util.to_bool(val)
    elif key == "copy_env":
        return util.to_bool(val)
    elif key == "env":
        return util.parse_env_dict(val)
    elif key == "cmd":
        return val
    elif key == "args":
        return 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)
    elif key == 'respawn':
        return util.to_bool(val)
    elif key.startswith('stderr_stream.') or key.startswith('stdout_stream.'):
        subkey = key.split('.', 1)[-1]
        if subkey in ('max_bytes', 'backup_count'):
            return int(val)
        return val
    elif key == 'hooks':
        res = {}
        for hook in val.split(','):
            if hook == '':
                continue
            hook = hook.split(':')
            if len(hook) != 2:
                raise ArgumentError(hook)

            name, value = hook
            if name not in _HOOKS:
                raise ArgumentError(name)

            res[name] = value

        return res
    elif key.startswith('hooks.'):
        # we can also set a single hook
        name = key.split('.', 1)[-1]
        if name not in _HOOKS:
            raise ArgumentError(name)
        return val

    raise ArgumentError("unknown key %r" % key)
        


src/c/i/circus-0.10.0/circus/commands/set.py   circus(Download)
from circus.commands.base import Command
from circus.commands.util import convert_option, validate_option
from circus.exc import ArgumentError, MessageError
 
 
            kv, args = args[:2], args[2:]
            kvl = kv[0].lower()
            options[kvl] = convert_option(kvl, kv[1])
 
        if opts.get('waiting', False):

src/c/i/circus-HEAD/circus/commands/set.py   circus(Download)
from circus.commands.base import Command
from circus.commands.util import convert_option, validate_option
from circus.exc import ArgumentError, MessageError
 
 
            kv, args = args[:2], args[2:]
            kvl = kv[0].lower()
            options[kvl] = convert_option(kvl, kv[1])
 
        if opts.get('waiting', False):

src/c/i/circus-0.10.0/circus/tests/test_convert_option.py   circus(Download)
from circus.tests.support import TestCase, EasyTestSuite
 
from circus.commands.util import convert_option, ArgumentError
 
 
class TestConvertOption(TestCase):
 
    def test_env(self):
        env = convert_option("env", {"port": "8080"})
 
        for option, value, expected in expected_convertions:
            ret = convert_option(option, value)
            self.assertEqual(ret, expected)
 
    def test_hooks(self):
        ret = convert_option('hooks', 'before_start:one')
        self.assertEqual(ret, {'before_start': 'one'})
 
        ret = convert_option('hooks', 'before_start:one,after_start:two')

src/c/i/circus-HEAD/circus/tests/test_convert_option.py   circus(Download)
from circus.tests.support import TestCase, EasyTestSuite
 
from circus.commands.util import convert_option, ArgumentError
 
 
class TestConvertOption(TestCase):
 
    def test_env(self):
        env = convert_option("env", {"port": "8080"})
 
        for option, value, expected in expected_convertions:
            ret = convert_option(option, value)
            self.assertEqual(ret, expected)
 
    def test_hooks(self):
        ret = convert_option('hooks', 'before_start:one')
        self.assertEqual(ret, {'before_start': 'one'})
 
        ret = convert_option('hooks', 'before_start:one,after_start:two')