Files
scwrypts/py/redis/interactive.py
T

27 lines
735 B
Python
Raw Normal View History

2022-04-28 16:09:23 -06:00
#!/usr/bin/env python
2023-02-21 18:44:27 -07:00
from py.lib.redis import get_client
from py.lib.scwrypts import execute, interactive, getenv
2022-04-28 16:09:23 -06:00
2023-02-21 18:44:27 -07:00
from py.lib.scwrypts.exceptions import ImportedExecutableError
2022-04-28 16:09:23 -06:00
2023-01-11 17:09:59 -07:00
if __name__ != '__main__':
2023-02-21 18:44:27 -07:00
raise ImportedExecutableError()
#####################################################################
2023-01-11 17:09:59 -07:00
2023-02-21 18:44:27 -07:00
@interactive([
f'r = StrictRedis(\'{getenv("REDIS_HOST")}:{getenv("REDIS_PORT")}\')',
])
def main(_args, _stream):
2023-01-11 17:09:59 -07:00
# pylint: disable=possibly-unused-variable
2023-02-21 18:44:27 -07:00
r = get_client()
2022-04-28 16:09:23 -06:00
return locals()
2023-02-21 18:44:27 -07:00
#####################################################################
execute(main,
description = 'establishes a redis client in an interactive python shell',
parse_args = [],
)