[CalendarServer-changes] [12851] CalendarServer/trunk/calendarserver/webadmin
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 7 15:08:46 PST 2014
Revision: 12851
http://trac.calendarserver.org//changeset/12851
Author: wsanchez at apple.com
Date: 2014-03-07 15:08:46 -0800 (Fri, 07 Mar 2014)
Log Message:
-----------
Prefix job attrs with "job_".
Handle cases where workItem() returns None without pooching the graph.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/webadmin/work.py
CalendarServer/trunk/calendarserver/webadmin/work.xhtml
Modified: CalendarServer/trunk/calendarserver/webadmin/work.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.py 2014-03-07 22:22:43 UTC (rev 12850)
+++ CalendarServer/trunk/calendarserver/webadmin/work.py 2014-03-07 23:08:46 UTC (rev 12851)
@@ -31,8 +31,10 @@
from zope.interface import implementer
from twisted.internet.defer import inlineCallbacks, returnValue
-# from twisted.web.template import tags as html, renderer
+from twext.python.log import Logger
+from twext.enterprise.jobqueue import JobItem
+
from txdav.caldav.datastore.scheduling.imip.inbound import (
IMIPPollingWork, IMIPReplyWork
)
@@ -45,8 +47,6 @@
ScheduleReplyWork, ScheduleAutoReplyWork,
)
-from twext.enterprise.jobqueue import JobItem
-
from .eventsource import EventSourceResource, IEventDecoder
from .resource import PageElement, TemplateResource
@@ -90,6 +90,9 @@
Resource that vends work queue information via HTML5 EventSource events.
"""
+ log = Logger()
+
+
def __init__(self, store, pollInterval=1000):
EventSourceResource.__init__(self, EventDecoder, bufferSize=100)
@@ -133,39 +136,61 @@
jobDicts = []
for job in jobs:
+ def formatTime(datetime):
+ if datetime is None:
+ return None
+ else:
+ # FIXME: Use HTTP time format
+ return datetime.ctime()
+
jobDict = dict(
- jobID=job.jobID,
- priority=job.priority,
- notBefore=job.notBefore.ctime(), # FIXME: HTTP format
- notAfter=job.notAfter,
+ job_jobID=job.jobID,
+ job_priority=job.priority,
+ job_notBefore=formatTime(job.notBefore),
+ job_notAfter=formatTime(job.notAfter),
)
work = yield job.workItem()
- if work is not None:
- if workType == PushNotificationWork:
- attrs = ("pushID", "priority")
- elif workType == ScheduleOrganizerWork:
- attrs = ("icalendarUid", "attendeeCount")
- elif workType == ScheduleRefreshWork:
- attrs = ("icalendarUid", "attendeeCount")
- elif workType == ScheduleReplyWork:
- attrs = ("icalendarUid",)
- elif workType == ScheduleAutoReplyWork:
- attrs = ("icalendarUid",)
- elif workType == GroupCacherPollingWork:
- attrs = ()
- elif workType == IMIPPollingWork:
- attrs = ()
- elif workType == IMIPReplyWork:
- attrs = ("organizer", "attendee")
- else:
- attrs = ()
+ attrs = ("workID", "group")
- for attr in attrs:
- jobDict["work_{}".format(attr)] = (
- getattr(work, attr)
+ if workType == PushNotificationWork:
+ attrs += ("pushID", "priority")
+ elif workType == ScheduleOrganizerWork:
+ attrs += ("icalendarUid", "attendeeCount")
+ elif workType == ScheduleRefreshWork:
+ attrs += ("icalendarUid", "attendeeCount")
+ elif workType == ScheduleReplyWork:
+ attrs += ("icalendarUid",)
+ elif workType == ScheduleAutoReplyWork:
+ attrs += ("icalendarUid",)
+ elif workType == GroupCacherPollingWork:
+ attrs += ()
+ elif workType == IMIPPollingWork:
+ attrs += ()
+ elif workType == IMIPReplyWork:
+ attrs += ("organizer", "attendee")
+ else:
+ attrs = ()
+
+ if attrs:
+ if work is None:
+ self.log.error(
+ "workItem() returned None for job: {job}",
+ job=job
)
+ # jobDict.update((attr, None) for attr in attrs)
+ for attr in attrs:
+ jobDict["work_{}".format(attr)] = None
+ else:
+ # jobDict.update(
+ # ("work_{}".format(attr), getattr(work, attr))
+ # for attr in attrs
+ # )
+ for attr in attrs:
+ jobDict["work_{}".format(attr)] = (
+ getattr(work, attr)
+ )
jobDicts.append(jobDict)
Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-07 22:22:43 UTC (rev 12850)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-07 23:08:46 UTC (rev 12851)
@@ -93,11 +93,17 @@
};
var jobAttributeDescriptions = {
- "jobID": "Job ID",
- "priority": "Job Priority",
- "notBefore": "Not Before",
- "notAfter": "Not After",
+ // Job management
+ "job_jobID": "Job ID",
+ "job_priority": "Job Priority",
+ "job_notBefore": "Not Before",
+ "job_notAfter": "Not After",
+ // Work item management
+ "work_workID": "Work ID",
+ "work_notBefore": "Not Before (W)",
+ "work_group": "Work Group",
+
// Push
"work_pushID": "Push ID",
"work_priority": "Priority",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140307/95da3446/attachment-0001.html>
More information about the calendarserver-changes
mailing list