Permalink
Browse files

pyflakes

  • Loading branch information...
1 parent f47a5a6 commit 5aa7d340f9da8da8b05be839721127ae46473c98 @ask ask committed Oct 3, 2011
View
0 contrib/release/bump_version.py 100644 → 100755
File mode changed.
View
3 cyme/api/views.py
@@ -1,12 +1,12 @@
"""cyme.api.views"""
from __future__ import absolute_import
+from __future__ import with_statement
import re
from celery import current_app as celery
from celery.result import AsyncResult
-from cl.pools import producers
from . import web
from ..branch.controller import apps, branches, instances, queues
@@ -49,6 +49,7 @@ def post(self, request, app, name=None, nowait=False):
**self.params("broker", "pool",
"arguments",
"extra_config")))
+
def put(self, *args, **kwargs):
return self.NotImplemented("Operation is not idempotent: use POST")
View
7 cyme/bin/base.py
@@ -5,7 +5,8 @@
"""
-from __future__ import absolute_import, with_statement
+from __future__ import absolute_import
+from __future__ import with_statement
from .. import __version__, DEBUG, DEBUG_BLOCK, DEBUG_READERS
@@ -39,10 +40,10 @@ def setup_eventlet(self):
eventlet.monkey_patch()
if DEBUG_READERS:
eventlet.debug.hub_prevent_multiple_readers(False)
- print("+++ MULTIPLE READERS ALLOWED +++")
+ print("+++ MULTIPLE READERS ALLOWED +++") # noqa+
if DEBUG_BLOCK:
eventlet.debug.hub_blocking_detection(True)
- print("+++ BLOCKING DETECTION ENABLED +++")
+ print("+++ BLOCKING DETECTION ENABLED +++") # noqa+
def configure(self):
from django.conf import settings
View
2 cyme/branch/__init__.py
@@ -19,7 +19,7 @@
from .state import state
from .thread import gThread
-from ..utils import find_symbol, instantiate, LazyProgressBar
+from ..utils import find_symbol, instantiate
class Branch(gThread):
View
4 cyme/branch/supervisor.py
@@ -1,6 +1,7 @@
"""cyme.branch.supervisor"""
-from __future__ import absolute_import, with_statement
+from __future__ import absolute_import
+from __future__ import with_statement
from threading import Lock
from Queue import Empty
@@ -173,7 +174,6 @@ def _verify_all(self, force=False):
ratelimit=True)
-
class _OfflineSupervisor(object):
def wait(self):
View
2 cyme/branch/thread.py
@@ -5,6 +5,7 @@
"""
from __future__ import absolute_import
+from __future__ import with_statement
import os
@@ -171,7 +172,6 @@ def _crashsafe(self, fun, *args, **kwargs):
signals.thread_exit.send(sender=self)
self.debug("exiting")
except Exception, exc:
- print("EXC: %r" % (exc, ))
self.error("Thread crash detected: %r", exc)
os._exit(0)
except self.Timeout, exc:
View
2 cyme/client/__init__.py
@@ -111,8 +111,6 @@
from .base import Path
from ..utils import cached_property
-
-
# XXX `requests` does not currently seem to support using the
# data argument with PUT requests.
View
6 cyme/client/base.py
@@ -52,8 +52,6 @@ def maybe_async(self, name, nowait):
return name
-
-
class Model(Document):
def __init__(self, parent, *args, **kwargs):
@@ -148,7 +146,7 @@ def _request(self, method, url, params=None, data=None, type=None):
data = self._prepare(data)
params = self._prepare(params)
if DEBUG:
- print("<REQ> %s %r data=%r params=%r" % (method, url,
+ print("<REQ> %s %r data=%r params=%r" % (method, url, # noqa+
data, params))
type = type or AttributeDict
r = requests.request(method, str(url),
@@ -157,7 +155,7 @@ def _request(self, method, url, params=None, data=None, type=None):
data = None
if DEBUG:
data = r.read()
- print("<RES> %r" % (data, ))
+ print("<RES> %r" % (data, )) # noqa+
if r.ok:
if data is None:
data = r.read()
View
19 cyme/management/commands/cyme.py
@@ -54,13 +54,14 @@
from __future__ import absolute_import
-import json
+import anyjson
import os
import pprint
-import sys
+from functools import partial
from inspect import getargspec
+
from celery import current_app as celery
from cyme.client import Client
from cyme.client.base import Model
@@ -69,13 +70,17 @@
from .base import CymeCommand, Option, die
-def json_pretty(obj, out=sys.stdout):
- return json.dumps(obj, out, indent=4)
+try:
+ import json as _json # Python 2.6+
+ json_pretty = partial(_json.dumps, indent=4)
+except ImportError:
+ json_pretty = anyjson.serialize # noqa
class I(object):
- def __init__(self, app=None, format=None, nowait=False, url=None, **kwargs):
+ def __init__(self, app=None, format=None, nowait=False,
+ url=None, **kwargs):
self.url = url
self.app = app
self.format = format or "pretty"
@@ -108,14 +113,12 @@ def __init__(self, app=None, format=None, nowait=False, url=None, **kwargs):
}
self.needs_app = ("instances", "queues")
self.formats = {"jsonp": json_pretty,
- "json": json.dumps,
+ "json": anyjson.serialize,
"pprint": pprint.pformat}
def getsig(self, fun, opt_args=None):
spec = getargspec(fun)
- print("DEFAULTS: %r" % (spec.args[:len(spec.defaults)], ))
args = spec.args[:-len(spec.defaults) if spec.defaults else None]
- print("SPEC: %r ARGS %r" % (spec, args, ))
if args[0] == "self":
args = args[1:]
if spec.defaults:
View
4 cyme/management/commands/cyme_branch.py
@@ -45,6 +45,7 @@
"""
from __future__ import absolute_import
+from __future__ import with_statement
import atexit
import os
@@ -55,7 +56,7 @@
from celery.bin.base import daemon_options
from celery.platforms import (create_pidlock, detached,
signals, set_process_title)
-from celery.utils.imports import get_cls_by_name, instantiate
+from celery.utils.imports import instantiate
from cl.utils import cached_property, shortuuid
from .base import CymeCommand, Option
@@ -184,7 +185,6 @@ def banner(self):
except AttributeError:
pres_interval = "(disabled)"
sup = branch.supervisor.thread
- from celery import current_app
return BANNER % {"id": branch.id,
"version": self.__version__,
"broker": branch.connection.as_uri(),
View
3 cyme/models/__init__.py
@@ -1,6 +1,7 @@
"""cyme.models"""
-from __future__ import absolute_import, with_statement
+from __future__ import absolute_import
+from __future__ import with_statement
import errno
import os
View
1 cyme/settings.py
@@ -1,5 +1,6 @@
"""Since cyme works as a contained Django APP, this is the default settings
file used when cyme is used outside of a Django project context."""
+from __future__ import absolute_import
import os
View
1 cyme/tasks.py
@@ -7,6 +7,7 @@
in the response.
"""
+from __future__ import absolute_import
from celery.task import task
from requests import request
View
2 cyme/tests/test_branch.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from celery.tests.utils import unittest
from mock import Mock
View
2 cyme/tests/test_models.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from celery.tests.utils import unittest
from mock import Mock

0 comments on commit 5aa7d34

Please sign in to comment.