From eb00f69cedea624cee5bf91eccde963cc1c35956 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 4 Oct 2012 16:57:49 -0700 Subject: [PATCH] Add a standard --url argument to all scripts. redis-py now supports URL-based connection configuration. When --url is specified, we use it to construct the Redis object. Otherwise, we use the existing argument-based construction method. `Redis.from_url()` is new in redis-py 2.6.2, so that prerequisite has been adjusted accordingly. --- rq/scripts/__init__.py | 9 +++++++-- setup.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rq/scripts/__init__.py b/rq/scripts/__init__.py index 69d7e2e..d0c9b48 100644 --- a/rq/scripts/__init__.py +++ b/rq/scripts/__init__.py @@ -5,6 +5,8 @@ from rq import use_connection def add_standard_arguments(parser): parser.add_argument('--config', '-c', default=None, help='Module containing RQ settings.') + parser.add_argument('--url', '-u', default=None, + help='URL describing Redis connection details') parser.add_argument('--host', '-H', default=None, help='The Redis hostname (default: localhost)') parser.add_argument('--port', '-p', default=None, @@ -44,6 +46,9 @@ def setup_default_arguments(args, settings): def setup_redis(args): - redis_conn = redis.Redis(host=args.host, port=args.port, db=args.db, - password=args.password) + if args.url is not None: + redis_conn = redis.Redis.from_url(args.url, db=args.db) + else: + redis_conn = redis.Redis(host=args.host, port=args.port, db=args.db, + password=args.password) use_connection(redis_conn) diff --git a/setup.py b/setup.py index 044bf8d..a5f989a 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ def get_version(): def get_dependencies(): - deps = ['redis >= 2.4.0', 'times'] + deps = ['redis >= 2.6.2', 'times'] deps += ['logbook'] # should be soft dependency? if sys.version_info < (2, 7) or \ (sys.version_info >= (3, 0) and sys.version_info < (3, 1)):