accept multiple path

main
kirill 8 years ago
parent 8ebebc9f7c
commit f2ff1b05f7

@ -134,7 +134,7 @@ def requeue(cli_config, all, job_class, job_ids, **options):
@main.command() @main.command()
@click.option('--path', '-P', default='.', help='Specify the import path.') @click.option('--path', '-P', default='.', help='Specify the import path.', multiple=True)
@click.option('--interval', '-i', type=float, help='Updates stats every N seconds (default: don\'t poll)') @click.option('--interval', '-i', type=float, help='Updates stats every N seconds (default: don\'t poll)')
@click.option('--raw', '-r', is_flag=True, help='Print only the raw numbers, no bar charts') @click.option('--raw', '-r', is_flag=True, help='Print only the raw numbers, no bar charts')
@click.option('--only-queues', '-Q', is_flag=True, help='Show only queue info') @click.option('--only-queues', '-Q', is_flag=True, help='Show only queue info')
@ -142,13 +142,10 @@ def requeue(cli_config, all, job_class, job_ids, **options):
@click.option('--by-queue', '-R', is_flag=True, help='Shows workers by queue') @click.option('--by-queue', '-R', is_flag=True, help='Shows workers by queue')
@click.argument('queues', nargs=-1) @click.argument('queues', nargs=-1)
@pass_cli_config @pass_cli_config
def info(cli_config, path, interval, raw, only_queues, only_workers, by_queue, queues, def info(cli_config, interval, raw, only_queues, only_workers, by_queue, queues,
**options): **options):
"""RQ command-line monitor.""" """RQ command-line monitor."""
if path:
sys.path = path.split(':') + sys.path
if only_queues: if only_queues:
func = show_queues func = show_queues
elif only_workers: elif only_workers:
@ -171,7 +168,7 @@ def info(cli_config, path, interval, raw, only_queues, only_workers, by_queue, q
@main.command() @main.command()
@click.option('--burst', '-b', is_flag=True, help='Run in burst mode (quit after all work is done)') @click.option('--burst', '-b', is_flag=True, help='Run in burst mode (quit after all work is done)')
@click.option('--name', '-n', help='Specify a different name') @click.option('--name', '-n', help='Specify a different name')
@click.option('--path', '-P', default='.', help='Specify the import path.') @click.option('--path', '-P', default='.', help='Specify the import path.', multiple=True)
@click.option('--results-ttl', type=int, help='Default results timeout to be used') @click.option('--results-ttl', type=int, help='Default results timeout to be used')
@click.option('--worker-ttl', type=int, help='Default worker timeout to be used') @click.option('--worker-ttl', type=int, help='Default worker timeout to be used')
@click.option('--verbose', '-v', is_flag=True, help='Show more output') @click.option('--verbose', '-v', is_flag=True, help='Show more output')
@ -181,14 +178,11 @@ def info(cli_config, path, interval, raw, only_queues, only_workers, by_queue, q
@click.option('--pid', help='Write the process ID number to a file at the specified path') @click.option('--pid', help='Write the process ID number to a file at the specified path')
@click.argument('queues', nargs=-1) @click.argument('queues', nargs=-1)
@pass_cli_config @pass_cli_config
def worker(cli_config, burst, name, path, results_ttl, def worker(cli_config, burst, name, results_ttl,
worker_ttl, verbose, quiet, sentry_dsn, exception_handler, worker_ttl, verbose, quiet, sentry_dsn, exception_handler,
pid, queues, **options): pid, queues, **options):
"""Starts an RQ worker.""" """Starts an RQ worker."""
if path:
sys.path = path.split(':') + sys.path
settings = read_config_file(cli_config.config) if cli_config.config else {} settings = read_config_file(cli_config.config) if cli_config.config else {}
# Worker specific default arguments # Worker specific default arguments
queues = queues or settings.get('QUEUES', ['default']) queues = queues or settings.get('QUEUES', ['default'])

@ -2,6 +2,7 @@
from __future__ import (absolute_import, division, print_function, from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
import sys
import importlib import importlib
import time import time
from functools import partial from functools import partial
@ -219,11 +220,15 @@ class CliConfig(object):
"""A helper class to be used with click commands, to handle shared options""" """A helper class to be used with click commands, to handle shared options"""
def __init__(self, url=None, config=None, worker_class=DEFAULT_WORKER_CLASS, def __init__(self, url=None, config=None, worker_class=DEFAULT_WORKER_CLASS,
job_class=DEFAULT_JOB_CLASS, queue_class=DEFAULT_QUEUE_CLASS, job_class=DEFAULT_JOB_CLASS, queue_class=DEFAULT_QUEUE_CLASS,
connection_class=DEFAULT_CONNECTION_CLASS, *args, **kwargs): connection_class=DEFAULT_CONNECTION_CLASS, path=None, *args, **kwargs):
self._connection = None self._connection = None
self.url = url self.url = url
self.config = config self.config = config
if path:
for pth in path:
sys.path.append(pth)
try: try:
self.worker_class = import_attribute(worker_class) self.worker_class = import_attribute(worker_class)
except (ImportError, AttributeError) as exc: except (ImportError, AttributeError) as exc:

Loading…
Cancel
Save