(app_name, app_conf, cli,
               delete_first=False, redis_key_prefix="")
return rv
A simple function to help you create redis config from a python dict.
    It intelligently stores string keys as strings and int keys as ints so
    that they can be eval'd on read.
    This mostly just serves as an example.

    `delete_first` (bool) if True, remove the app config first
    `redis_key_prefix` if redis keys used by Stolos have a prefix, specify it

        >> app_name = 'myapp1'
        >> app_conf = {"bash_cmd": "echo 123"}
        >> cli = redis.StrictRedis()
        >> set_config(app_name, app_conf, cli, delete_first=True)
        [True]
        >> cli.hgetall("%s%s" % ('', app_name))
        {"'bash_cmd'": "'echo 123'"}
A simple function to help you create redis config from a python dict.
    It intelligently stores string keys as strings and int keys as ints so
    that they can be eval'd on read.
    This mostly just serves as an example.
A simple function to help you create redis config from a python dict . It intelligently stores string keys as strings and int keys as ints so that they can be eval d on read . This mostly just serves as an example .
def set_config(app_name, app_conf, cli,
               delete_first=False, redis_key_prefix=""):
    """
    A simple function to help you create redis config from a python dict.
    It intelligently stores string keys as strings and int keys as ints so
    that they can be eval'd on read.
    This mostly just serves as an example.

    `delete_first` (bool) if True, remove the app config first
    `redis_key_prefix` if redis keys used by Stolos have a prefix, specify it

        >> app_name = 'myapp1'
        >> app_conf = {"bash_cmd": "echo 123"}
        >> cli = redis.StrictRedis()
        >> set_config(app_name, app_conf, cli, delete_first=True)
        [True]
        >> cli.hgetall("%s%s" % ('', app_name))
        {"'bash_cmd'": "'echo 123'"}

    """
    key = '%s%s' % (redis_key_prefix, app_name)
    with cli.pipeline(transaction=True) as pipe:
        if delete_first:
            pipe.delete(key)
        pipe.hmset(key, {repr(k): repr(v) for k, v in app_conf.items()})
        rv = pipe.execute()
    if not rv[-1]:
        raise Exception(
            "Failed to set app config data",
            extra=dict(app_name=app_name, app_config=app_conf))
    return rv
def set_config ( app_name , app_conf , cli , delete_first = False , redis_key_prefix = "" ) : key = '%s%s' % ( redis_key_prefix , app_name ) with cli . pipeline ( transaction = True ) as pipe : if delete_first : pipe . delete ( key ) pipe . hmset ( key , { repr ( k ) : repr ( v ) for k , v in app_conf . items ( ) } ) rv = pipe . execute ( ) if not rv [ - 1 ] : raise Exception ( "Failed to set app config data" , extra = dict ( app_name = app_name , app_config = app_conf ) ) return rv