diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2023-11-04 18:52:12 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2023-11-04 18:52:12 +0000 |
commit | a596894f2d782b9df54c026696e55da1267f7936 (patch) | |
tree | e2696ad38feb91700ac875966e6aa0b30e732566 /iredis | |
parent | Adding upstream version 1.13.1. (diff) | |
download | iredis-a596894f2d782b9df54c026696e55da1267f7936.tar.xz iredis-a596894f2d782b9df54c026696e55da1267f7936.zip |
Adding upstream version 1.14.0.upstream/1.14.0
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'iredis')
-rw-r--r-- | iredis/__init__.py | 2 | ||||
-rw-r--r-- | iredis/client.py | 11 | ||||
-rw-r--r-- | iredis/commands.py | 2 | ||||
-rw-r--r-- | iredis/completers.py | 1 | ||||
-rw-r--r-- | iredis/config.py | 5 | ||||
-rw-r--r-- | iredis/data/iredisrc | 4 | ||||
-rw-r--r-- | iredis/entry.py | 22 | ||||
-rw-r--r-- | iredis/markdown.py | 4 |
8 files changed, 38 insertions, 13 deletions
diff --git a/iredis/__init__.py b/iredis/__init__.py index 4b67c39..b9f68ed 100644 --- a/iredis/__init__.py +++ b/iredis/__init__.py @@ -1 +1 @@ -__version__ = "1.13.1" +__version__ = "1.14.0" diff --git a/iredis/client.py b/iredis/client.py index bbdb87c..f7164b8 100644 --- a/iredis/client.py +++ b/iredis/client.py @@ -4,9 +4,10 @@ IRedis client. import re import os import sys +import codecs import logging from subprocess import run -from importlib_resources import read_text +from importlib.resources import read_text from packaging.version import parse as version_parse import redis @@ -94,6 +95,7 @@ class Client: try: self.connection.connect() except Exception as e: + logger.exception("Can not create connection to server") print(str(e), file=sys.stderr) sys.exit(1) if not config.no_info: @@ -282,6 +284,7 @@ class Client: connection.connect() logger.info(f"New connection created, retry on {connection}.") logger.info(f"send_command: {command_name} , {args}") + connection.send_command(command_name, *args) response = connection.read_response() except AuthenticationError: @@ -547,6 +550,12 @@ class Client: if command_name.upper() in ["ZSCAN", "ZPOPMAX", "ZPOPMIN"]: config.withscores = True + # TODO should we using escape_decode on all strings?? + if command_name.upper() == "RESTORE": + for i, a in enumerate(args): + serialized_value = codecs.escape_decode(a)[0] + args[i] = serialized_value + # not a tty if not completer: logger.warning( diff --git a/iredis/commands.py b/iredis/commands.py index fcbe2a4..cf21a54 100644 --- a/iredis/commands.py +++ b/iredis/commands.py @@ -3,7 +3,7 @@ import csv import json import logging import functools -from importlib_resources import read_text, open_text +from importlib.resources import read_text, open_text from .utils import timer, strip_quote_args from .exceptions import InvalidArguments, AmbiguousCommand diff --git a/iredis/completers.py b/iredis/completers.py index e3ebb5a..6f9ecac 100644 --- a/iredis/completers.py +++ b/iredis/completers.py @@ -105,7 +105,6 @@ class TimestampCompleter(Completer): now = pendulum.now() for unit, minimum in self.when_lower_than.items(): if current <= minimum: - if self.future_time: dt = now.add(**{f"{unit}s": current}) offset_text = "later" diff --git a/iredis/config.py b/iredis/config.py index ea27827..4041bb6 100644 --- a/iredis/config.py +++ b/iredis/config.py @@ -1,4 +1,4 @@ -from importlib_resources import path +from importlib.resources import path import os import logging @@ -63,6 +63,8 @@ class Config: self.withscores = False self.version = "Unknown" + self.greetings = True + self.prompt = None def __setter__(self, name, value): @@ -129,5 +131,6 @@ def load_config_files(iredisrc): config.pager = config_obj["main"].get("pager") config.enable_pager = config_obj["main"].as_bool("enable_pager") config.prompt = config_obj["main"].get("prompt") + config.greetings = config_obj["main"].as_bool("greetings") return config_obj diff --git a/iredis/data/iredisrc b/iredis/data/iredisrc index 6db02a7..978aa4b 100644 --- a/iredis/data/iredisrc +++ b/iredis/data/iredisrc @@ -76,6 +76,10 @@ prompt = # History file location history_location = ~/.iredis_history +# if set to True, will display version information on startup +# can set to False to disable it. +greetings = True + [alias_dsn] # example_dsn = redis://[[username]:[password]]@localhost:6379/0 # example_dsn = rediss://[[username]:[password]]@localhost:6379/0 diff --git a/iredis/entry.py b/iredis/entry.py index c7ae76c..0799a07 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -61,8 +61,8 @@ def greetings(): reason = "" server_version = f"redis-server {config.version} {reason}" - home_page = "Home: https://iredis.io" - issues = "Issues: https://iredis.io/issues" + home_page = "Home: https://iredis.xbin.io/" + issues = "Issues: https://github.com/laixintao/iredis/issues" display = "\n".join([iredis_version, server_version, home_page, issues]) if config.raw: display = display.encode() @@ -177,9 +177,9 @@ def repl(client, session, start_time): try: command = session.prompt( prompt_message(client), - bottom_toolbar=BottomToolbar(command_holder).render - if config.bottom_bar - else None, + bottom_toolbar=( + BottomToolbar(command_holder).render if config.bottom_bar else None + ), input_processors=[ UpdateBottomProcessor(command_holder, session), PasswordProcessor(), @@ -275,6 +275,12 @@ VERIFY_SSL_HELP = """Set the TLS certificate verification strategy""" @click.option("--shell/--no-shell", default=None, is_flag=True, help=SHELL) @click.option("--pager/--no-pager", default=None, is_flag=True, help=PAGER_HELP) @click.option( + "--greetings/--no-greetings", + default=None, + is_flag=True, + help="Enable or disable greeting messages", +) +@click.option( "--verify-ssl", default=None, type=click.Choice(["none", "optional", "required"]), @@ -309,6 +315,7 @@ def gather_args( socket, shell, pager, + greetings, verify_ssl, prompt, ): @@ -354,6 +361,8 @@ def gather_args( config.enable_pager = pager if verify_ssl is not None: config.verify_ssl = verify_ssl + if greetings is not None: + config.greetings = greetings return ctx @@ -492,5 +501,6 @@ def main(): ) # print hello message - greetings() + if config.greetings: + greetings() repl(client, session, enter_main_time) diff --git a/iredis/markdown.py b/iredis/markdown.py index 6f26642..89297ec 100644 --- a/iredis/markdown.py +++ b/iredis/markdown.py @@ -30,7 +30,7 @@ class TerminalRender(mistune.HTMLRenderer): return super().heading(header_text, 2) return super().heading(self._to_title(text), level) - def list(self, body, ordered, level, start=None): + def list(self, body, ordered, *args, **kwargs): """Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. @@ -41,7 +41,7 @@ class TerminalRender(mistune.HTMLRenderer): tag = "ol" return "<%s>%s</%s>\n" % (tag, body, tag) - def list_item(self, text, level): + def list_item(self, text, *args): """Rendering list item snippet. Like ``<li>``.""" return "<li> * %s</li>\n" % text |