diff --git a/Products/Jobber/manager.py b/Products/Jobber/manager.py index 64f17deff7..4daca3d0ac 100644 --- a/Products/Jobber/manager.py +++ b/Products/Jobber/manager.py @@ -515,8 +515,12 @@ def _getByStatusAndType(statuses, jobtype=None): def _getJobTypeStr(jobtype): if isinstance(jobtype, type): - return jobtype.name - task = app.tasks.get(str(jobtype)) - if not task: - raise ValueError("No such job: {!r}".format(jobtype)) - return task.name + name = jobtype.name + else: + task = app.tasks.get(str(jobtype)) + if not task: + raise ValueError("No such task: {!r}".format(jobtype)) + name = task.name + if name is None: + raise ValueError("zenjobs task name is None: {!r}".format(jobtype)) + return name diff --git a/Products/Jobber/meta.py b/Products/Jobber/meta.py index d158a43ff0..f5e1b71866 100644 --- a/Products/Jobber/meta.py +++ b/Products/Jobber/meta.py @@ -45,7 +45,7 @@ def job(_context, **kw): if not task.name or task.name not in app.tasks: try: registered_task = app.register_task(task) - setattr(registered_task.__class__, 'name', registered_task.name) + registered_task.__class__.name = registered_task.name except Exception as e: raise Exception("Task registration failed: %s" % e) diff --git a/Products/Jobber/storage.py b/Products/Jobber/storage.py index aeeb03df43..9607c96ed0 100644 --- a/Products/Jobber/storage.py +++ b/Products/Jobber/storage.py @@ -15,6 +15,8 @@ from collections import Container, Iterable, Sized +import six + from celery import states as celery_states from Products.ZenUtils.RedisUtils import getRedisClient @@ -101,7 +103,7 @@ class _Any(object): """ def __init__(self, *matches): - if not all(isinstance(m, basestring) for m in matches): + if not all(isinstance(m, six.string_types) for m in matches): raise ValueError( "All values must be strings %s" % (matches,), ) @@ -174,7 +176,7 @@ def search(self, **fields): for name, match in fields.items(): # Note: check for string first because strings are also # iterable. - if isinstance(match, basestring): + if isinstance(match, six.string_types): matchers[name] = match elif isinstance(match, Iterable): matchers[name] = _Any(*match) diff --git a/Products/Jobber/task/base.py b/Products/Jobber/task/base.py index d1d4db134d..9ebc1b35e7 100644 --- a/Products/Jobber/task/base.py +++ b/Products/Jobber/task/base.py @@ -41,7 +41,7 @@ def __new__(cls, *args, **kwargs): summary = getattr(task, "summary", None) if not summary: summary = _default_summary.format(task) - setattr(cls, "summary", summary) + cls.summary = summary task.max_retries = getConfig().get("zodb-max-retries", 5)