Pull argument parser defaults from environment variables.

main
Malthe Borch 11 years ago
parent dbcba85815
commit e77b3e8a21

@ -1,3 +1,4 @@
import os
import importlib import importlib
import redis import redis
from warnings import warn from warnings import warn
@ -7,18 +8,25 @@ from rq import use_connection
def add_standard_arguments(parser): def add_standard_arguments(parser):
parser.add_argument('--config', '-c', default=None, parser.add_argument('--config', '-c', default=None,
help='Module containing RQ settings.') help='Module containing RQ settings.')
parser.add_argument('--url', '-u', default=None, parser.add_argument('--url', '-u',
default=os.environ.get('RQ_REDIS_URL'),
help='URL describing Redis connection details. ' help='URL describing Redis connection details. '
'Overrides other connection arguments if supplied.') 'Overrides other connection arguments if '
parser.add_argument('--host', '-H', default=None, 'supplied.')
parser.add_argument('--host', '-H',
default=os.environ.get('RQ_REDIS_HOST', 'localhost'),
help='The Redis hostname (default: localhost)') help='The Redis hostname (default: localhost)')
parser.add_argument('--port', '-p', default=None, parser.add_argument('--port', '-p',
default=int(os.environ.get('RQ_REDIS_PORT', 6379)),
help='The Redis portnumber (default: 6379)') help='The Redis portnumber (default: 6379)')
parser.add_argument('--db', '-d', type=int, default=None, parser.add_argument('--db', '-d', type=int,
default=int(os.environ.get('RQ_REDIS_DB', 0)),
help='The Redis database (default: 0)') help='The Redis database (default: 0)')
parser.add_argument('--password', '-a', default=None, parser.add_argument('--password', '-a',
default=os.environ.get('RQ_REDIS_PASSWORD'),
help='The Redis password (default: None)') help='The Redis password (default: None)')
parser.add_argument('--socket', '-s', default=None, parser.add_argument('--socket', '-s',
default=os.environ.get('RQ_REDIS_SOCKET'),
help='The Redis Unix socket') help='The Redis Unix socket')

Loading…
Cancel
Save