Skip to content

Commit

Permalink
pyflakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ask Solem committed Mar 18, 2010
1 parent da875ec commit a3c2c53
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 51 deletions.
3 changes: 2 additions & 1 deletion celery/backends/base.py
Expand Up @@ -181,7 +181,8 @@ def reload_task_result(self, task_id):
self._cache[task_id] = self.get_task_meta(task_id, cache=False)

def reload_taskset_result(self, taskset_id):
self._cache[taskset_id] = self.get_taskset_meta(taskset_id, cache=False)
self._cache[taskset_id] = self.get_taskset_meta(taskset_id,
cache=False)

def get_taskset_meta(self, taskset_id, cache=True):
if cache and taskset_id in self._cache:
Expand Down
24 changes: 6 additions & 18 deletions celery/bin/camqadm.py
Expand Up @@ -3,18 +3,11 @@
.. program:: camqadm
.. cmdoption:: -X, --x
Description
"""
import os
import cmd
import sys
import shlex
import pprint
import readline
import optparse
from itertools import count

Expand All @@ -25,7 +18,6 @@
from celery.utils import padlist
from celery.messaging import establish_connection


# Valid string -> bool coercions.
BOOLS = {"1": True, "0": False,
"on": True, "off": False,
Expand All @@ -35,12 +27,7 @@
# Map to coerce strings to other types.
COERCE = {bool: lambda value: BOOLS[value.lower()]}

OPTION_LIST = (
#optparse.make_option('-c', '--concurrency',
# default=conf.CELERYD_CONCURRENCY,
# action="store", dest="concurrency", type="int",
# help="Number of child processes processing the queue."),
)
OPTION_LIST = ()

HELP_HEADER = """
Commands
Expand Down Expand Up @@ -134,6 +121,7 @@ def dump_message(message):
"properties": message.properties,
"delivery_info": message.delivery_info}


def format_declare_queue(ret):
return "ok. queue:%s messages:%s consumers:%s." % ret

Expand Down Expand Up @@ -165,9 +153,9 @@ class AMQShell(cmd.Cmd):
counter = 1
inc_counter = count(2).next

builtins = {"exit": "do_exit",
"EOF": "do_exit",
"help": "do_help",}
builtins = {"EOF": "do_exit",
"exit": "do_exit",
"help": "do_help"}

amqp = {
"exchange.declare": Spec(("exchange", str),
Expand Down Expand Up @@ -381,7 +369,7 @@ def camqadm(*args, **options):

def main():
options, values = parse_options(sys.argv[1:])
return run_worker(*values, **vars(options))
return camqadm(*values, **vars(options))

if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion celery/task/base.py
Expand Up @@ -211,7 +211,8 @@ def establish_connection(self,

@classmethod
def get_publisher(self, connection=None, exchange=None,
connect_timeout=conf.BROKER_CONNECTION_TIMEOUT,exchange_type=None):
connect_timeout=conf.BROKER_CONNECTION_TIMEOUT,
exchange_type=None):
"""Get a celery task message publisher.
:rtype: :class:`celery.messaging.TaskPublisher`.
Expand Down
1 change: 0 additions & 1 deletion celery/tests/test_backends/test_amqp.py
@@ -1,5 +1,4 @@
import sys
import errno
import unittest2 as unittest

from celery.exceptions import ImproperlyConfigured
Expand Down
1 change: 0 additions & 1 deletion celery/tests/test_backends/test_redis.py
@@ -1,5 +1,4 @@
import sys
import errno
import socket
import unittest2 as unittest

Expand Down
1 change: 0 additions & 1 deletion celery/tests/test_backends/test_tyrant.py
@@ -1,5 +1,4 @@
import sys
import errno
import socket
import unittest2 as unittest

Expand Down
8 changes: 2 additions & 6 deletions celery/tests/test_loaders.py
Expand Up @@ -2,8 +2,6 @@
import sys
import unittest2 as unittest

from billiard.utils.functional import wraps

from celery import loaders
from celery.loaders import base
from celery.loaders import djangoapp
Expand Down Expand Up @@ -53,7 +51,6 @@ def test_handlers_pass(self):
self.loader.on_worker_init()

def test_import_task_module(self):
import sys
self.assertEqual(sys, self.loader.import_task_module("sys"))

def test_conf_property(self):
Expand All @@ -62,9 +59,8 @@ def test_conf_property(self):
self.assertEqual(self.loader.conf.foo, "bar")

def test_import_default_modules(self):
import os
import sys
self.assertSameElements(self.loader.import_default_modules(), [os, sys])
self.assertSameElements(self.loader.import_default_modules(),
[os, sys])


class TestDjangoLoader(unittest.TestCase):
Expand Down
1 change: 0 additions & 1 deletion celery/tests/test_task_http.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import generators

import sys
import logging
import unittest2 as unittest
from urllib import addinfourl
Expand Down
2 changes: 0 additions & 2 deletions celery/tests/test_utils.py
Expand Up @@ -2,8 +2,6 @@
import socket
import unittest2 as unittest

from billiard.utils.functional import wraps

from celery import utils

from celery.tests.utils import sleepdeprived, execute_context
Expand Down
4 changes: 1 addition & 3 deletions celery/tests/test_views.py
@@ -1,8 +1,6 @@
import sys
import unittest

from django.http import HttpResponse
from django.test.client import Client
from django.test.testcases import TestCase as DjangoTestCase
from django.core.urlresolvers import reverse
from django.template import TemplateDoesNotExist
Expand Down Expand Up @@ -59,7 +57,7 @@ class TestTaskApply(ViewTestCase):
def test_apply(self):
conf.ALWAYS_EAGER = True
try:
ret = self.client.get(task_apply(kwargs={"task_name":
self.client.get(task_apply(kwargs={"task_name":
mytask.name}) + "?x=4&y=4")
self.assertEqual(scratch["result"], 16)
finally:
Expand Down
4 changes: 2 additions & 2 deletions celery/tests/test_worker.py
Expand Up @@ -8,9 +8,9 @@
from billiard.serialization import pickle

from celery import conf
from celery.utils import gen_unique_id, noop
from celery.utils import gen_unique_id
from celery.worker import WorkController
from celery.worker.listener import CarrotListener, RUN, CLOSE
from celery.worker.listener import CarrotListener, RUN
from celery.worker.job import TaskWrapper
from celery.worker.scheduler import Scheduler
from celery.decorators import task as task_dec
Expand Down
23 changes: 12 additions & 11 deletions celery/tests/test_worker_job.py
Expand Up @@ -197,7 +197,7 @@ def mock_mail_admins(*args, **kwargs):
tw = TaskWrapper(mytask.name, gen_unique_id(), [1], {"f": "x"})
try:
raise KeyError("foo")
except KeyError, exc:
except KeyError:
einfo = ExceptionInfo(sys.exc_info())

tw.on_failure(einfo)
Expand Down Expand Up @@ -242,7 +242,7 @@ def with_catch_warnings(log):
def create_exception(self, exc):
try:
raise exc
except exc.__class__, thrown:
except exc.__class__:
return sys.exc_info()

def test_worker_task_trace_handle_retry(self):
Expand Down Expand Up @@ -376,15 +376,16 @@ def test_execute_using_pool(self):
def test_default_kwargs(self):
tid = gen_unique_id()
tw = TaskWrapper(mytask.name, tid, [4], {"f": "x"})
self.assertDictEqual(tw.extend_with_default_kwargs(10, "some_logfile"), {
"f": "x",
"logfile": "some_logfile",
"loglevel": 10,
"task_id": tw.task_id,
"task_retries": 0,
"task_is_eager": False,
"delivery_info": {},
"task_name": tw.task_name})
self.assertDictEqual(
tw.extend_with_default_kwargs(10, "some_logfile"), {
"f": "x",
"logfile": "some_logfile",
"loglevel": 10,
"task_id": tw.task_id,
"task_retries": 0,
"task_is_eager": False,
"delivery_info": {},
"task_name": tw.task_name})

def test_on_failure(self):
tid = gen_unique_id()
Expand Down
2 changes: 2 additions & 0 deletions celery/utils/info.py
Expand Up @@ -39,6 +39,7 @@ def format_routing_table(table=None, indent=0):
for name, route in table.items())
return textindent(routes, indent=indent)


def get_broker_info():
broker_connection = establish_connection()

Expand All @@ -61,6 +62,7 @@ def get_broker_info():
"port": port,
"vhost": vhost}


def format_broker_info(info=None):
"""Get message broker connection info string for log dumps."""
return BROKER_FORMAT % get_broker_info()
4 changes: 2 additions & 2 deletions celery/worker/buckets.py
Expand Up @@ -174,8 +174,8 @@ def clear(self):
try:
bucket.clear()
except AttributeError:
# Probably a Queue, not a TokenBucketQueue. Clear the underlying
# deque instead.
# Probably a Queue, not a TokenBucketQueue, so clear the
# underlying deque instead.
bucket.queue.clear()


Expand Down
8 changes: 8 additions & 0 deletions docs/reference/celery.bin.camqadm.rst
@@ -0,0 +1,8 @@
===========================================================
caqmadm: AMQP API Command-line Shell - celery.bin.camqadm
===========================================================

.. currentmodule:: celery.bin.camqadm

.. automodule:: celery.bin.camqadm
:members:
1 change: 1 addition & 0 deletions docs/reference/index.rst
Expand Up @@ -32,3 +32,4 @@
celery.bin.celeryd
celery.bin.celerybeat
celery.bin.celeryinit
celery.bin.camqadm
1 change: 1 addition & 0 deletions docs/userguide/index.rst
Expand Up @@ -11,3 +11,4 @@
tasks
executing
remote-tasks
routing
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -112,7 +112,7 @@ class QuickRunTests(RunTests):
'celeryinit = celery.bin.celeryinit:main',
'celerybeat = celery.bin.celerybeat:main',
'camqadm = celery.bin.camqadm:main',
]
],
},
long_description=long_description,
)

0 comments on commit a3c2c53

Please sign in to comment.