Exemplo n.º 1
0
def format_colors(record, handler):
    from rq.utils import make_colorizer
    if record.level == logbook.WARNING:
        colorize = make_colorizer('darkyellow')
    elif record.level >= logbook.ERROR:
        colorize = make_colorizer('darkred')
    else:
        colorize = lambda x: x
    return '%s: %s' % (record.time.strftime('%H:%M:%S'), colorize(record.msg))
Exemplo n.º 2
0
def format_colors(record, handler):
    from rq.utils import make_colorizer
    if record.level == logbook.WARNING:
        colorize = make_colorizer('darkyellow')
    elif record.level >= logbook.ERROR:
        colorize = make_colorizer('darkred')
    else:
        colorize = lambda x: x
    return '%s: %s' % (record.time.strftime('%H:%M:%S'), colorize(record.msg))
Exemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import time
import argparse
from redis.exceptions import ConnectionError
from rq import Queue, Worker
from rq.utils import gettermsize, make_colorizer
from rq.scripts import add_standard_arguments
from rq.scripts import setup_redis
from rq.scripts import read_config_file
from rq.scripts import setup_default_arguments

red = make_colorizer('darkred')
green = make_colorizer('darkgreen')
yellow = make_colorizer('darkyellow')


def pad(s, pad_to_length):
    """Pads the given string to the given length."""
    return ('%-' + '%ds' % pad_to_length) % (s,)

def get_scale(x):
    """Finds the lowest scale where x <= scale."""
    scales = [20, 50, 100, 200, 400, 600, 800, 1000]
    for scale in scales:
        if x <= scale:
            return scale
    return x
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import time
import argparse
from redis.exceptions import ConnectionError
from rq import Queue, Worker
from rq.utils import gettermsize, make_colorizer
from rq.scripts import add_standard_arguments
from rq.scripts import setup_redis

red = make_colorizer('darkred')
green = make_colorizer('darkgreen')
yellow = make_colorizer('darkyellow')


def pad(s, pad_to_length):
    """Pads the given string to the given length."""
    return ('%-' + '%ds' % pad_to_length) % (s, )


def get_scale(x):
    """Finds the lowest scale where x <= scale."""
    scales = [20, 50, 100, 200, 400, 600, 800, 1000]
    for scale in scales:
        if x <= scale:
            return scale
    return x

Exemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import time
import argparse
from redis.exceptions import ConnectionError
from rq import Queue, Worker
from rq.utils import gettermsize, make_colorizer
from rq.scripts import add_standard_arguments
from rq.scripts import setup_redis
from rq.scripts import read_config_file
from rq.scripts import setup_default_arguments

red = make_colorizer("darkred")
green = make_colorizer("darkgreen")
yellow = make_colorizer("darkyellow")


def pad(s, pad_to_length):
    """Pads the given string to the given length."""
    return ("%-" + "%ds" % pad_to_length) % (s,)


def get_scale(x):
    """Finds the lowest scale where x <= scale."""
    scales = [20, 50, 100, 200, 400, 600, 800, 1000]
    for scale in scales:
        if x <= scale:
            return scale
    return x
Exemplo n.º 6
0
import os
import re
import sys
import time
from abc import ABCMeta, abstractmethod
import irods.keywords as kw
import irods.exception as ex
import irodsqueue.config as config

from redis import Redis
from rq import Queue

from rq.utils import make_colorizer
from rq.connections import get_current_connection

yellow = make_colorizer('yellow')

logger = logging.getLogger('rq.worker')


class IrodsChecksum(metaclass=ABCMeta):
    @abstractmethod
    def __init__(self):
        pass

    def update(self, data):
        self._hasher.update(data)

    def digest(self):
        return self._hasher.digest()
Exemplo n.º 7
0
#from .job import Job, JobStatus
#from .logutils import setup_loghandlers
#from .queue import Queue, get_failed_queue
#from .registry import FinishedJobRegistry, StartedJobRegistry, clean_registries
#from .suspension import is_suspended
#from .timeouts import UnixSignalDeathPenalty
#from .utils_tg import (ensure_list, enum, import_attribute, make_colorizer,
#                    utcformat, utcnow, utcparse)
#from .version import VERSION

#from .worker import Worker

import matlab.engine
logging.basicConfig(level=logging.DEBUG)

green = make_colorizer('darkgreen')
yellow = make_colorizer('darkyellow')
blue = make_colorizer('darkblue')


class TgWorker(Worker):
    def main_work_horse(self, *args, **kwargs):
        raise NotImplementedError("Test worker does not implement this method")

    def execute_job(self, *args, **kwargs):
        """Execute job in same thread/process, do not fork()"""
        logging.debug('executing from tgworker')
        DEFAULT_WORKER_TTL = 1000
        DEFAULT_RESULT_TTL = 1000
        logger = logging.getLogger(__name__)
        logging.debug('checking to start engine in ej')
Exemplo n.º 8
0
Arquivo: cli.py Projeto: luisbc92/rq
from rq.defaults import (DEFAULT_CONNECTION_CLASS, DEFAULT_JOB_CLASS,
                         DEFAULT_QUEUE_CLASS, DEFAULT_WORKER_CLASS,
                         DEFAULT_RESULT_TTL, DEFAULT_WORKER_TTL,
                         DEFAULT_JOB_MONITORING_INTERVAL,
                         DEFAULT_LOGGING_FORMAT, DEFAULT_LOGGING_DATE_FORMAT,
                         DEFAULT_SERIALIZER_CLASS)
from rq.exceptions import InvalidJobOperationError
from rq.registry import FailedJobRegistry, clean_registries
from rq.utils import import_attribute, get_call_string, make_colorizer
from rq.serializers import DefaultSerializer
from rq.suspension import (suspend as connection_suspend, resume as
                           connection_resume, is_suspended)
from rq.worker_registration import clean_worker_registry
from rq.job import JobStatus

blue = make_colorizer('darkblue')

# Disable the warning that Click displays (as of Click version 5.0) when users
# use unicode_literals in Python 2.
# See http://click.pocoo.org/dev/python3/#unicode-literals for more details.
click.disable_unicode_literals_warning = True

shared_options = [
    click.option('--url',
                 '-u',
                 envvar='RQ_REDIS_URL',
                 help='URL describing Redis connection details.'),
    click.option('--config',
                 '-c',
                 envvar='RQ_CONFIG',
                 help='Module containing RQ settings.'),
Exemplo n.º 9
0
import logging
import os
import signal
import sys
import time
import traceback
from rq.connections import Connection, get_current_connection
from rq.exceptions import NoQueueError, UnpickleError, DequeueTimeout
from rq.job import Job, Status
from rq.logutils import setup_loghandlers
from rq.queue import Queue, get_failed_queue
from rq.utils import make_colorizer

logger = logging.getLogger(__name__)

green = make_colorizer('darkgreen')

def iterable(x):
    return hasattr(x, '__iter__')

_signames = dict((getattr(signal, signame), signame)
        for signame in dir(signal)
        if signame.startswith('SIG') and '_' not in signame)

def signal_name(signum):
    try:
        return _signames[signum]
    except KeyError:
        return 'SIG_UNKNOWN'

class Worker(object):