[CalendarServer-changes] [12359] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:17:19 PDT 2014
Revision: 12359
http://trac.calendarserver.org//changeset/12359
Author: cdaboo at apple.com
Date: 2014-01-16 09:46:32 -0800 (Thu, 16 Jan 2014)
Log Message:
-----------
Make sure all cli tools use a service class derived from WorkerService. Also add an assert to ensure that is the case.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/calverify.py
CalendarServer/trunk/calendarserver/tools/cmdline.py
CalendarServer/trunk/calendarserver/tools/dbinspect.py
CalendarServer/trunk/calendarserver/tools/export.py
CalendarServer/trunk/calendarserver/tools/migrate_verify.py
CalendarServer/trunk/calendarserver/tools/obliterate.py
CalendarServer/trunk/calendarserver/tools/shell/terminal.py
CalendarServer/trunk/calendarserver/tools/test/test_calverify.py
CalendarServer/trunk/calendarserver/tools/upgrade.py
CalendarServer/trunk/calendarserver/tools/validcalendardata.py
CalendarServer/trunk/calendarserver/tools/workitems.py
Property Changed:
----------------
CalendarServer/trunk/
Property changes on: CalendarServer/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/release/CalendarServer-5.2-dev:11972
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/json:11622-11912
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
+ /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/release/CalendarServer-5.2-dev:11972,12357-12358
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/json:11622-11912
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
Modified: CalendarServer/trunk/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/calverify.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -54,7 +54,6 @@
from pycalendar.period import Period
from pycalendar.timezone import Timezone
-from twisted.application.service import Service
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python import usage
from twisted.python.usage import Options
@@ -78,7 +77,7 @@
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
from txdav.common.icommondatastore import InternalDataStoreError
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
from calendarserver.tools import tables
from calendarserver.tools.util import getDirectory
@@ -386,14 +385,13 @@
-class CalVerifyService(Service, object):
+class CalVerifyService(WorkerService, object):
"""
Base class for common service behaviors.
"""
def __init__(self, store, options, output, reactor, config):
- super(CalVerifyService, self).__init__()
- self.store = store
+ super(CalVerifyService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
@@ -409,32 +407,12 @@
self.totalExceptions = None
- def startService(self):
- """
- Start the service.
- """
- super(CalVerifyService, self).startService()
- self.doCalVerify()
-
-
- def stopService(self):
- """
- Stop the service. Nothing to do; everything should be finished by this
- time.
- """
- # TODO: stopping this service mid-export should really stop the export
- # loop, but this is not implemented because nothing will actually do it
- # except hitting ^C (which also calls reactor.stop(), so that will exit
- # anyway).
- pass
-
-
def title(self):
return ""
@inlineCallbacks
- def doCalVerify(self):
+ def doWork(self):
"""
Do the operation stopping the reactor when done.
"""
@@ -444,11 +422,9 @@
yield self.doAction()
self.output.close()
except:
- log.failure("doCalVerify()")
+ log.failure("doWork()")
- self.reactor.stop()
-
def directoryService(self):
"""
Get an appropriate directory service for this L{CalVerifyService}'s
@@ -2792,7 +2768,8 @@
self.output.write("\n")
self.output.write("Actual RECURRENCE-ID: %s.\n" % (rid,))
- oldUID = yield calendarObj.split(rid=rid)
+ oldObj = yield calendarObj.split(rid=rid)
+ oldUID = oldObj.uid()
self.output.write("\n")
self.output.write("Split Resource: %s at %s, old UID: %s.\n" % (resid, rid, oldUID,))
Modified: CalendarServer/trunk/calendarserver/tools/cmdline.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/cmdline.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/cmdline.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -68,6 +68,13 @@
will be imported and used.
"""
+ # We want to validate that the actual service is always an instance of WorkerService, so wrap the
+ # service maker callback inside a function that does that check
+ def _makeValidService(store):
+ service = serviceClass(store)
+ assert isinstance(service, WorkerService)
+ return service
+
# Install std i/o observer
if verbose:
observer = StandardIOObserver()
@@ -83,7 +90,7 @@
checkDirectories(config)
config.ProcessType = "Utility"
- config.UtilityServiceClass = serviceClass
+ config.UtilityServiceClass = _makeValidService
autoDisableMemcached(config)
@@ -172,5 +179,8 @@
By default, stop the reactor after doWork( ) finishes. Subclasses
can override this if they want different behavior.
"""
- from twisted.internet import reactor
- reactor.stop()
+ if hasattr(self, "reactor"):
+ self.reactor.stop()
+ else:
+ from twisted.internet import reactor
+ reactor.stop()
Modified: CalendarServer/trunk/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dbinspect.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/dbinspect.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -23,12 +23,11 @@
"""
from calendarserver.tools import tables
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
from pycalendar.datetime import DateTime
from twext.enterprise.dal.syntax import Select, Parameter, Count, Delete, \
Constant
-from twisted.application.service import Service
-from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.defer import inlineCallbacks, returnValue, succeed
from twisted.python.filepath import FilePath
from twisted.python.text import wordWrap
from twisted.python.usage import Options
@@ -851,14 +850,13 @@
-class DBInspectService(Service, object):
+class DBInspectService(WorkerService, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
"""
def __init__(self, store, options, reactor, config):
- super(DBInspectService, self).__init__()
- self.store = store
+ super(DBInspectService, self).__init__(store)
self.options = options
self.reactor = reactor
self.config = config
@@ -866,11 +864,10 @@
self.commandMap = {}
- def startService(self):
+ def doWork(self):
"""
Start the service.
"""
- super(DBInspectService, self).startService()
# Register commands
self.registerCommand(TableSizes)
@@ -890,7 +887,16 @@
self.registerCommand(EventsInTimerange)
self.doDBInspect()
+ return succeed(None)
+
+ def postStartService(self):
+ """
+ Don't quit right away
+ """
+ pass
+
+
def registerCommand(self, cmd):
self.commands.append(cmd.name())
self.commandMap[cmd.name()] = cmd
Modified: CalendarServer/trunk/calendarserver/tools/export.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/export.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/export.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -42,13 +42,12 @@
from twisted.python.text import wordWrap
from twisted.python.usage import Options, UsageError
from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.application.service import Service
from twext.python.log import Logger
from twistedcaldav.ical import Component
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
log = Logger()
@@ -285,14 +284,13 @@
-class ExporterService(Service, object):
+class ExporterService(WorkerService, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
"""
def __init__(self, store, options, output, reactor, config):
- super(ExporterService, self).__init__()
- self.store = store
+ super(ExporterService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
@@ -300,16 +298,8 @@
self._directory = self.store.directoryService()
- def startService(self):
- """
- Start the service.
- """
- super(ExporterService, self).startService()
- self.doExport()
-
-
@inlineCallbacks
- def doExport(self):
+ def doWork(self):
"""
Do the export, stopping the reactor when done.
"""
@@ -326,11 +316,9 @@
# update stuff needed to happen, don't want to undo it.
self.output.close()
except:
- log.failure("doExport()")
+ log.failure("doWork()")
- self.reactor.stop()
-
def directoryService(self):
"""
Get an appropriate directory service.
Modified: CalendarServer/trunk/calendarserver/tools/migrate_verify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/migrate_verify.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/migrate_verify.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -17,9 +17,6 @@
##
from __future__ import print_function
-from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
-from twext.enterprise.dal.syntax import Select, Parameter
-
"""
This tool takes a list of files paths from a file store being migrated
and compares that to the results of a migration to an SQL store. Items
@@ -29,16 +26,19 @@
import os
import sys
-from twisted.application.service import Service
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python.text import wordWrap
from twisted.python.usage import Options
+from twext.enterprise.dal.syntax import Select, Parameter
from twext.python.log import Logger
+
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
-from calendarserver.tools.cmdline import utilityMain
+from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
+from calendarserver.tools.cmdline import utilityMain, WorkerService
+
log = Logger()
VERSION = "1"
@@ -118,14 +118,13 @@
-class MigrateVerifyService(Service, object):
+class MigrateVerifyService(WorkerService, object):
"""
Service which runs, does its stuff, then stops the reactor.
"""
def __init__(self, store, options, output, reactor, config):
- super(MigrateVerifyService, self).__init__()
- self.store = store
+ super(MigrateVerifyService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
@@ -141,16 +140,8 @@
self.missingResources = []
- def startService(self):
- """
- Start the service.
- """
- super(MigrateVerifyService, self).startService()
- self.doMigrateVerify()
-
-
@inlineCallbacks
- def doMigrateVerify(self):
+ def doWork(self):
"""
Do the work, stopping the reactor when done.
"""
@@ -163,11 +154,9 @@
except ConfigError:
pass
except:
- log.failure("doMigrateVerify()")
+ log.failure("doWork()")
- self.reactor.stop()
-
def readPaths(self):
self.output.write("-- Reading data file: %s\n" % (self.options["data"]))
Modified: CalendarServer/trunk/calendarserver/tools/obliterate.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/obliterate.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/obliterate.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -30,7 +30,6 @@
import sys
import time
-from twisted.application.service import Service
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.python.text import wordWrap
from twisted.python.usage import Options
@@ -42,7 +41,7 @@
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
log = Logger()
@@ -138,14 +137,13 @@
-class ObliterateService(Service, object):
+class ObliterateService(WorkerService, object):
"""
Service which runs, does its stuff, then stops the reactor.
"""
def __init__(self, store, options, output, reactor, config):
- super(ObliterateService, self).__init__()
- self.store = store
+ super(ObliterateService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
@@ -159,16 +157,8 @@
self.attachments = set()
- def startService(self):
- """
- Start the service.
- """
- super(ObliterateService, self).startService()
- self.doObliterate()
-
-
@inlineCallbacks
- def doObliterate(self):
+ def doWork(self):
"""
Do the work, stopping the reactor when done.
"""
@@ -186,11 +176,9 @@
except ConfigError:
pass
except:
- log.failure("doObliterate()")
+ log.failure("doWork()")
- self.reactor.stop()
-
@inlineCallbacks
def obliterateOrphanedProperties(self):
"""
Modified: CalendarServer/trunk/calendarserver/tools/shell/terminal.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/terminal.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/shell/terminal.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -38,12 +38,11 @@
from twisted.python.failure import Failure
from twisted.python.text import wordWrap
from twisted.python.usage import Options, UsageError
-from twisted.internet.defer import Deferred
+from twisted.internet.defer import Deferred, succeed
from twisted.internet.defer import inlineCallbacks
from twisted.internet.stdio import StandardIO
from twisted.conch.recvline import HistoricRecvLine as ReceiveLineProtocol
from twisted.conch.insults.insults import ServerProtocol
-from twisted.application.service import Service
from twext.python.log import Logger
@@ -51,7 +50,7 @@
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
from calendarserver.tools.util import getDirectory
from calendarserver.tools.shell.cmd import Commands, UsageError as CommandUsageError
@@ -95,7 +94,7 @@
-class ShellService(Service, object):
+class ShellService(WorkerService, object):
"""
A L{ShellService} collects all the information that a shell needs to run;
when run, it invokes the shell on stdin/stdout.
@@ -117,21 +116,19 @@
"""
def __init__(self, store, directory, options, reactor, config):
- super(ShellService, self).__init__()
- self.store = store
- self.directory = directory
- self.options = options
- self.reactor = reactor
- self.config = config
+ super(ShellService, self).__init__(store)
+ self.directory = directory
+ self.options = options
+ self.reactor = reactor
+ self.config = config
self.terminalFD = None
- self.protocol = None
+ self.protocol = None
- def startService(self):
+ def doWork(self):
"""
- Start the service.
+ Service startup.
"""
- super(ShellService, self).startService()
# Set up the terminal for interactive action
self.terminalFD = sys.__stdin__.fileno()
@@ -140,8 +137,16 @@
self.protocol = ServerProtocol(lambda: ShellProtocol(self))
StandardIO(self.protocol)
+ return succeed(None)
+ def postStartService(self):
+ """
+ Don't quit right away
+ """
+ pass
+
+
def stopService(self):
"""
Stop the service.
@@ -280,7 +285,7 @@
word = ""
else:
word = tokens[-1]
- cmd = tokens.pop(0)
+ cmd = tokens.pop(0)
else:
word = cmd = ""
Modified: CalendarServer/trunk/calendarserver/tools/test/test_calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_calverify.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/test/test_calverify.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -3066,8 +3066,7 @@
}
output = StringIO()
calverify = EventSplitService(self._sqlCalendarStore, options, output, reactor, config)
- oldObj = yield calverify.doAction()
- oldUID = oldObj.uid()
+ oldUID = yield calverify.doAction()
relsubs = dict(self.subs)
relsubs["relID"] = oldUID
Modified: CalendarServer/trunk/calendarserver/tools/upgrade.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/upgrade.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/upgrade.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -25,15 +25,15 @@
import sys
import time
+from twisted.internet.defer import succeed
from twisted.python.text import wordWrap
from twisted.python.usage import Options, UsageError
from twext.python.log import Logger, LogLevel, formatEvent, addObserver
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
-from twisted.application.service import Service
-from calendarserver.tools.cmdline import utilityMain
+from calendarserver.tools.cmdline import utilityMain, WorkerService
from calendarserver.tap.caldav import CalDAVServiceMaker
log = Logger()
@@ -122,7 +122,7 @@
-class UpgraderService(Service, object):
+class UpgraderService(WorkerService, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
"""
@@ -130,8 +130,7 @@
started = False
def __init__(self, store, options, output, reactor, config):
- super(UpgraderService, self).__init__()
- self.store = store
+ super(UpgraderService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
@@ -139,7 +138,7 @@
self._directory = None
- def startService(self):
+ def doWork(self):
"""
Immediately stop. The upgrade will have been run before this.
"""
@@ -155,7 +154,13 @@
else:
self.output.write("Upgrade complete, shutting down.\n")
UpgraderService.started = True
+ return succeed(None)
+
+ def postStartService(self):
+ """
+ Quit right away
+ """
from twisted.internet import reactor
from twisted.internet.error import ReactorNotRunning
try:
Modified: CalendarServer/trunk/calendarserver/tools/validcalendardata.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/validcalendardata.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/validcalendardata.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -21,8 +21,8 @@
for the server.
"""
-from calendarserver.tools.cmdline import utilityMain
-from twisted.application.service import Service
+from calendarserver.tools.cmdline import utilityMain, WorkerService
+from twisted.internet.defer import succeed
from twisted.python.text import wordWrap
from twisted.python.usage import Options
from twistedcaldav.config import config
@@ -119,14 +119,13 @@
errorPrefix = "Calendar data had unfixable problems:\n "
-class ValidService(Service, object):
+class ValidService(WorkerService, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
"""
def __init__(self, store, options, output, input, reactor, config):
- super(ValidService, self).__init__()
- self.store = store
+ super(ValidService, self).__init__(store)
self.options = options
self.output = output
self.input = input
@@ -135,7 +134,7 @@
self._directory = None
- def startService(self):
+ def doWork(self):
"""
Start the service.
"""
@@ -149,7 +148,7 @@
print("Calendar data OK")
else:
print(message)
- self.reactor.stop()
+ return succeed(None)
def parseCalendarData(self):
Modified: CalendarServer/trunk/calendarserver/tools/workitems.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/workitems.py 2014-01-16 16:52:43 UTC (rev 12358)
+++ CalendarServer/trunk/calendarserver/tools/workitems.py 2014-01-16 17:46:32 UTC (rev 12359)
@@ -23,9 +23,8 @@
import curses
import datetime
-from twisted.internet.defer import inlineCallbacks
-from calendarserver.tools.cmdline import utilityMain
-from twisted.application.service import Service
+from twisted.internet.defer import inlineCallbacks, succeed
+from calendarserver.tools.cmdline import utilityMain, WorkerService
from calendarserver.push.notifier import PushNotificationWork
from twistedcaldav.directory.directory import GroupCacherPollingWork
from txdav.caldav.datastore.scheduling.imip.inbound import IMIPPollingWork, IMIPReplyWork
@@ -86,21 +85,29 @@
-class WorkItemMonitorService(Service):
+class WorkItemMonitorService(WorkerService, object):
def __init__(self, store):
- self.store = store
+ super(WorkItemMonitorService, self).__init__(store)
from twisted.internet import reactor
self.reactor = reactor
- def startService(self):
+ def doWork(self):
self.screen = curses.initscr()
self.windows = []
self.updateScreenGeometry()
self.reactor.callLater(0, self.updateDisplay)
+ return succeed(None)
+ def postStartService(self):
+ """
+ Don't quit right away
+ """
+ pass
+
+
def updateScreenGeometry(self):
for win in self.windows:
del win
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/7c0c0a0f/attachment.html>
More information about the calendarserver-changes
mailing list