[CalendarServer-changes] [14520] CalendarServer/branches/users/cdaboo/pod2pod-migration

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 6 13:20:35 PST 2015


Revision: 14520
          http://trac.calendarserver.org//changeset/14520
Author:   cdaboo at apple.com
Date:     2015-03-06 13:20:35 -0800 (Fri, 06 Mar 2015)
Log Message:
-----------
Merge from trunk.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py
    CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/sharing_invites.py
    CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py
    CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/util.py

Property Changed:
----------------
    CalendarServer/branches/users/cdaboo/pod2pod-migration/


Property changes on: CalendarServer/branches/users/cdaboo/pod2pod-migration
___________________________________________________________________
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,12357-12358,12794,12814
/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/scheduling-queue-refresh:11783-12557
/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/groupsharee2:13669-13773
/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/move2who:12819-12860
/CalendarServer/branches/users/sagen/move2who-2:12861-12898
/CalendarServer/branches/users/sagen/move2who-3:12899-12913
/CalendarServer/branches/users/sagen/move2who-4:12914-13157
/CalendarServer/branches/users/sagen/move2who-5:13158-13163
/CalendarServer/branches/users/sagen/newcua:13309-13327
/CalendarServer/branches/users/sagen/newcua-1:13328-13330
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/recordtypes:13648-13656
/CalendarServer/branches/users/sagen/recordtypes-2:13657
/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/psycopg2cffi:14427-14439
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:14338-14507
   + /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,12794,12814
/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/scheduling-queue-refresh:11783-12557
/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/groupsharee2:13669-13773
/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/move2who:12819-12860
/CalendarServer/branches/users/sagen/move2who-2:12861-12898
/CalendarServer/branches/users/sagen/move2who-3:12899-12913
/CalendarServer/branches/users/sagen/move2who-4:12914-13157
/CalendarServer/branches/users/sagen/move2who-5:13158-13163
/CalendarServer/branches/users/sagen/newcua:13309-13327
/CalendarServer/branches/users/sagen/newcua-1:13328-13330
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/recordtypes:13648-13656
/CalendarServer/branches/users/sagen/recordtypes-2:13657
/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/psycopg2cffi:14427-14439
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:14338-14519

Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py	2015-03-06 20:13:58 UTC (rev 14519)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py	2015-03-06 21:20:35 UTC (rev 14520)
@@ -38,6 +38,7 @@
 from twisted.internet.defer import Deferred
 from txdav.base.datastore.dbapiclient import DBAPIConnector
 from txdav.base.datastore.dbapiclient import postgresPreflight
+from txdav.common.datastore.sql_tables import splitSQLString
 from txdav.common.icommondatastore import InternalDataStoreError
 
 from twisted.application.service import MultiService
@@ -411,20 +412,20 @@
             )
         except:
             # database already exists
-            executeSQL = False
+            sqlToExecute = None
         else:
             # database does not yet exist; if dump file exists, execute it,
             # otherwise execute schema
-            executeSQL = True
             sqlToExecute = self.schema
 
         createDatabaseCursor.close()
         createDatabaseConn.close()
 
-        if executeSQL:
+        if sqlToExecute is not None:
             connection = self.produceConnection()
             cursor = connection.cursor()
-            cursor.execute(sqlToExecute)
+            for statement in splitSQLString(sqlToExecute):
+                cursor.execute(statement)
             connection.commit()
             connection.close()
 

Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/sharing_invites.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/sharing_invites.py	2015-03-06 20:13:58 UTC (rev 14519)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/sharing_invites.py	2015-03-06 21:20:35 UTC (rev 14520)
@@ -26,33 +26,45 @@
     """
 
     @inlineCallbacks
-    def send_shareinvite(self, txn, homeType, ownerUID, ownerName, shareeUID, shareUID, bindMode, bindUID, summary, copy_properties, supported_components):
+    def send_shareinvite(
+        self, txn, homeType, ownerUID, ownerName, shareeUID, shareUID,
+        bindMode, bindUID, summary, copy_properties, supported_components
+    ):
         """
         Send a sharing invite cross-pod message.
 
         @param homeType: Type of home being shared.
         @type homeType: C{int}
+
         @param ownerUID: UID of the sharer.
         @type ownerUID: C{str}
+
         @param ownerName: owner's name of the sharer calendar
         @type ownerName: C{str}
+
         @param shareeUID: UID of the sharee
         @type shareeUID: C{str}
+
         @param shareUID: Resource/invite ID for sharee
         @type shareUID: C{str}
+
         @param bindMode: bind mode for the share
         @type bindMode: C{str}
         @param bindUID: bind UID of the sharer calendar
         @type bindUID: C{str}
         @param summary: sharing message
         @type summary: C{str}
+
         @param copy_properties: C{str} name/value for properties to be copied
         @type copy_properties: C{dict}
+
         @param supported_components: supproted components, may be C{None}
         @type supported_components: C{str}
         """
 
-        _ignore_sender, recipient = yield self.validRequest(ownerUID, shareeUID)
+        _ignore_sender, recipient = yield self.validRequest(
+            ownerUID, shareeUID
+        )
 
         request = {
             "action": "shareinvite",
@@ -75,14 +87,17 @@
     @inlineCallbacks
     def recv_shareinvite(self, txn, request):
         """
-        Process a sharing invite cross-pod request. Request arguments as per L{send_shareinvite}.
+        Process a sharing invite cross-pod request.
+        Request arguments as per L{send_shareinvite}.
 
         @param request: request arguments
         @type request: C{dict}
         """
 
         # Sharee home on this pod must exist (create if needed)
-        shareeHome = yield txn.homeWithUID(request["type"], request["sharee"], create=True)
+        shareeHome = yield txn.homeWithUID(
+            request["type"], request["sharee"], create=True
+        )
         if shareeHome is None or shareeHome.external():
             raise FailedCrossPodRequestError("Invalid sharee UID specified")
 
@@ -100,23 +115,31 @@
 
 
     @inlineCallbacks
-    def send_shareuninvite(self, txn, homeType, ownerUID, bindUID, shareeUID, shareUID):
+    def send_shareuninvite(
+        self, txn, homeType, ownerUID,
+        bindUID, shareeUID, shareUID
+    ):
         """
         Send a sharing uninvite cross-pod message.
 
         @param homeType: Type of home being shared.
         @type homeType: C{int}
+
         @param ownerUID: UID of the sharer.
         @type ownerUID: C{str}
         @param bindUID: bind UID of the sharer calendar
         @type bindUID: C{str}
+
         @param shareeUID: UID of the sharee
         @type shareeUID: C{str}
+
         @param shareUID: Resource/invite ID for sharee
         @type shareUID: C{str}
         """
 
-        _ignore_sender, recipient = yield self.validRequest(ownerUID, shareeUID)
+        _ignore_sender, recipient = yield self.validRequest(
+            ownerUID, shareeUID
+        )
 
         request = {
             "action": "shareuninvite",
@@ -133,7 +156,8 @@
     @inlineCallbacks
     def recv_shareuninvite(self, txn, request):
         """
-        Process a sharing uninvite cross-pod request. Request arguments as per L{send_shareuninvite}.
+        Process a sharing uninvite cross-pod request.
+        Request arguments as per L{send_shareuninvite}.
 
         @param request: request arguments
         @type request: C{dict}
@@ -153,7 +177,10 @@
 
 
     @inlineCallbacks
-    def send_sharereply(self, txn, homeType, ownerUID, shareeUID, shareUID, bindStatus, summary=None):
+    def send_sharereply(
+        self, txn, homeType, ownerUID,
+        shareeUID, shareUID, bindStatus, summary=None
+    ):
         """
         Send a sharing reply cross-pod message.
 
@@ -171,7 +198,9 @@
         @type summary: C{str}
         """
 
-        _ignore_sender, recipient = yield self.validRequest(shareeUID, ownerUID)
+        _ignore_sender, recipient = yield self.validRequest(
+            shareeUID, ownerUID
+        )
 
         request = {
             "action": "sharereply",
@@ -190,7 +219,8 @@
     @inlineCallbacks
     def recv_sharereply(self, txn, request):
         """
-        Process a sharing reply cross-pod request. Request arguments as per L{send_sharereply}.
+        Process a sharing reply cross-pod request.
+        Request arguments as per L{send_sharereply}.
 
         @param request: request arguments
         @type request: C{dict}

Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py	2015-03-06 20:13:58 UTC (rev 14519)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py	2015-03-06 21:20:35 UTC (rev 14520)
@@ -72,9 +72,9 @@
         txn = self.transactionUnderTest()
         cs = schema.CALENDARSERVER
         version = (yield Select(
-            [cs.VALUE, ],
+            [cs.VALUE],
             From=cs,
-            Where=cs.NAME == 'VERSION',
+            Where=cs.NAME == "VERSION",
         ).on(txn))
         self.assertNotEqual(version, None)
         self.assertEqual(len(version), 1)

Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/util.py	2015-03-06 20:13:58 UTC (rev 14519)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/util.py	2015-03-06 21:20:35 UTC (rev 14520)
@@ -108,10 +108,13 @@
     def __init__(self, count=0):
         self.sharedService = None
         self.currentTestID = None
-        self.sharedDBPath = "_test_sql_db" + str(os.getpid()) + ("-{}".format(count) if count else "")
         self.ampPort = config.WorkQueue.ampPort + count
 
+        self.sharedDBPath = "_test_sql_db-{}-{}".format(
+            os.getpid(), count
+        )
 
+
     def createService(self, serviceFactory):
         """
         Create a L{PostgresService} to use for building a store.
@@ -157,7 +160,10 @@
         return cds
 
 
-    def buildStore(self, testCase, notifierFactory, directoryService=None, homes=None, enableJobProcessing=True):
+    def buildStore(
+        self, testCase, notifierFactory,
+        directoryService=None, homes=None, enableJobProcessing=True,
+    ):
         """
         Do the necessary work to build a store for a particular test case.
 
@@ -169,34 +175,45 @@
         # The directory will be given to us later via setDirectoryService
         if self.sharedService is None:
             ready = Deferred()
+
             def getReady(connectionFactory, storageService):
                 self.makeAndCleanStore(
-                    testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing
+                    testCase, notifierFactory, directoryService,
+                    attachmentRoot, enableJobProcessing
                 ).chainDeferred(ready)
                 return Service()
+
             self.sharedService = self.createService(getReady)
             self.sharedService.startService()
+
             def startStopping():
                 log.info("Starting stopping.")
                 self.sharedService.unpauseMonitor()
                 return self.sharedService.stopService()
-            reactor.addSystemEventTrigger(#@UndefinedVariable
+
+            reactor.addSystemEventTrigger(
                 "before", "shutdown", startStopping)
             result = ready
         else:
             result = self.makeAndCleanStore(
-                testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing
+                testCase, notifierFactory, directoryService,
+                attachmentRoot, enableJobProcessing
             )
+
         def cleanUp():
             def stopit():
                 self.sharedService.pauseMonitor()
             return deferLater(reactor, 0.1, stopit)
+
         testCase.addCleanup(cleanUp)
         return result
 
 
     @inlineCallbacks
-    def makeAndCleanStore(self, testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing=True):
+    def makeAndCleanStore(
+        self, testCase, notifierFactory, directoryService,
+        attachmentRoot, enableJobProcessing=True
+    ):
         """
         Create a L{CommonDataStore} specific to the given L{TestCase}.
 
@@ -213,14 +230,19 @@
         attachmentRoot.createDirectory()
 
         currentTestID = testCase.id()
-        cp = ConnectionPool(self.sharedService.produceConnection, maxConnections=4)
+        cp = ConnectionPool(
+            self.sharedService.produceConnection, maxConnections=4
+        )
         quota = deriveQuota(testCase)
         store = CommonDataStore(
             cp.connection,
             {"push": notifierFactory} if notifierFactory is not None else {},
             directoryService,
             attachmentRoot,
-            "https://example.com/calendars/__uids__/%(home)s/attachments/%(name)s",
+            (
+                "https://example.com/calendars/__uids__/"
+                "%(home)s/attachments/%(name)s"
+            ),
             quota=quota
         )
         store.label = currentTestID
@@ -279,11 +301,13 @@
         # table' statements are issued, so it's not possible to reference a
         # later table.  Therefore it's OK to drop them in the (reverse) order
         # that they happen to be in.
-        tables = [t.name for t in schema.model.tables #@UndefinedVariable
-                  # All tables with rows _in_ the schema are populated
-                  # exclusively _by_ the schema and shouldn't be manipulated
-                  # while the server is running, so we leave those populated.
-                  if not t.schemaRows][::-1]
+        tables = [
+            t.name for t in schema.model.tables #@UndefinedVariable
+            # All tables with rows _in_ the schema are populated
+            # exclusively _by_ the schema and shouldn't be manipulated
+            # while the server is running, so we leave those populated.
+            if not t.schemaRows
+        ][::-1]
 
         for table in tables:
             try:
@@ -453,24 +477,32 @@
             try:
                 if config.RestrictCalendarsToOneComponentType:
                     for name in ical.allowedStoreComponents:
-                        yield home.removeCalendarWithName(home._componentCalendarName[name])
+                        yield home.removeCalendarWithName(
+                            home._componentCalendarName[name]
+                        )
                 else:
                     yield home.removeCalendarWithName("calendar")
                 yield home.removeCalendarWithName("inbox")
             except NoSuchHomeChildError:
                 pass
+
             for calendarName in calendars:
                 calendarObjNames = calendars[calendarName]
+
                 if calendarObjNames is not None:
                     # XXX should not be yielding!  this SQL will be executed
                     # first!
                     yield home.createCalendarWithName(calendarName)
                     calendar = yield home.calendarWithName(calendarName)
+
                     for objectName in calendarObjNames:
                         objData, metadata = calendarObjNames[objectName]
+
                         yield calendar._createCalendarObjectWithNameInternal(
                             objectName,
-                            VComponent.fromString(updateToCurrentYear(objData)),
+                            VComponent.fromString(
+                                updateToCurrentYear(objData)
+                            ),
                             internal_state=ComponentUpdateState.RAW,
                             options=metadata,
                         )
@@ -481,7 +513,8 @@
 
 def updateToCurrentYear(data):
     """
-    Update the supplied iCalendar data so that all dates are updated to the current year.
+    Update the supplied iCalendar data so that all dates are updated to the
+    current year.
     """
 
     nowYear = DateTime.getToday().getYear()
@@ -493,7 +526,8 @@
 
 def componentUpdate(data):
     """
-    Update the supplied iCalendar data so that all dates are updated to the current year.
+    Update the supplied iCalendar data so that all dates are updated to the
+    current year.
     """
 
     if len(relativeDateSubstitutions) == 0:
@@ -540,10 +574,12 @@
                     calendar = yield home.calendarWithName(calendarName)
                     for objectName in calendarObjNames:
                         md5 = calendarObjNames[objectName]
-                        obj = yield calendar.calendarObjectWithName(
-                            objectName,
+                        obj = (
+                            yield calendar.calendarObjectWithName(objectName)
                         )
-                        obj.properties()[md5key] = TwistedGETContentMD5.fromString(md5)
+                        obj.properties()[md5key] = (
+                            TwistedGETContentMD5.fromString(md5)
+                        )
     yield populateTxn.commit()
 
 
@@ -574,7 +610,9 @@
                     # XXX should not be yielding!  this SQL will be executed
                     # first!
                     yield home.createAddressBookWithName(addressbookName)
-                    addressbook = yield home.addressbookWithName(addressbookName)
+                    addressbook = (
+                        yield home.addressbookWithName(addressbookName)
+                    )
                     for objectName in addressbookObjNames:
                         objData = addressbookObjNames[objectName]
                         yield addressbook.createAddressBookObjectWithName(
@@ -605,13 +643,17 @@
                 if addressbookObjNames is not None:
                     # XXX should not be yielding!  this SQL will be executed
                     # first!
-                    addressbook = yield home.addressbookWithName(addressbookName)
+                    addressbook = (
+                        yield home.addressbookWithName(addressbookName)
+                    )
                     for objectName in addressbookObjNames:
                         md5 = addressbookObjNames[objectName]
                         obj = yield addressbook.addressbookObjectWithName(
                             objectName,
                         )
-                        obj.properties()[md5key] = TwistedGETContentMD5.fromString(md5)
+                        obj.properties()[md5key] = (
+                            TwistedGETContentMD5.fromString(md5)
+                        )
     yield populateTxn.commit()
 
 
@@ -634,8 +676,8 @@
 
 
 def buildTestDirectory(
-    store, dataRoot, accounts=None, resources=None, augments=None, proxies=None,
-    serversDB=None, cacheSeconds=0
+    store, dataRoot, accounts=None, resources=None, augments=None,
+    proxies=None, serversDB=None, cacheSeconds=0,
 ):
     """
     @param store: the store for the directory to use
@@ -745,7 +787,8 @@
     @inlineCallbacks
     def buildStoreAndDirectory(
         self, accounts=None, resources=None, augments=None, proxies=None,
-        extraUids=None, serversDB=None, cacheSeconds=0, storeBuilder=theStoreBuilder
+        extraUids=None, serversDB=None, cacheSeconds=0,
+        storeBuilder=theStoreBuilder,
     ):
 
         self.serverRoot = self.mktemp()
@@ -798,10 +841,12 @@
         if not os.path.exists(config.LogRoot):
             os.makedirs(config.LogRoot)
 
-        # Work queues for implicit scheduling slow down tests a lot and require them all to add
-        # "waits" for work to complete. Rewriting all the current tests to do that is not practical
-        # right now, so we will turn this off by default. Instead we will have a set of tests dedicated
-        # to work queue-based scheduling which will patch this option to True.
+        # Work queues for implicit scheduling slow down tests a lot and require
+        # them all to add "waits" for work to complete.
+        # Rewriting all the current tests to do that is not practical right
+        # now, so we will turn this off by default.
+        # Instead we will have a set of tests dedicated to work queue-based
+        # scheduling which will patch this option to True.
         config.Scheduling.Options.WorkQueues.Enabled = False
 
         self.config = config
@@ -835,20 +880,25 @@
         """
         if self.savedStore is None:
             self.savedStore = self.storeUnderTest()
+
         self.counter += 1
+
         if txn is None:
             txn = self.savedStore.newTransaction(
                 self.id() + " #" + str(self.counter)
             )
         else:
             txn._label = self.id() + " #" + str(self.counter)
+
         @inlineCallbacks
         def maybeCommitThis():
             try:
                 yield txn.commit()
             except AlreadyFinishedError:
                 pass
+
         self.addCleanup(maybeCommitThis)
+
         return txn
 
 
@@ -879,14 +929,13 @@
         return self.store
 
 
-    @inlineCallbacks
     def homeUnderTest(self, txn=None, name="home1", status=None, create=False):
         """
         Get the calendar home detailed by C{requirements['home1']}.
         """
         if txn is None:
             txn = self.transactionUnderTest()
-        returnValue((yield txn.calendarHomeWithUID(name, status=status, create=create)))
+        return txn.calendarHomeWithUID(name, status=status, create=create)
 
 
     @inlineCallbacks
@@ -894,19 +943,24 @@
         """
         Get the calendar detailed by C{requirements['home1']['calendar_1']}.
         """
-        returnValue((
-            yield (yield self.homeUnderTest(txn, name=home, status=status)).calendarWithName(name)
-        ))
+        home = yield self.homeUnderTest(txn, home, status=status)
+        calendar = yield home.calendarWithName(name)
+        returnValue(calendar)
 
 
     @inlineCallbacks
-    def calendarObjectUnderTest(self, txn=None, name="1.ics", calendar_name="calendar_1", home="home1", status=None):
+    def calendarObjectUnderTest(
+        self, txn=None, name="1.ics", calendar_name="calendar_1", home="home1", status=None
+    ):
         """
         Get the calendar detailed by
         C{requirements[home][calendar_name][name]}.
         """
-        returnValue((yield (yield self.calendarUnderTest(txn, name=calendar_name, home=home, status=status))
-                     .calendarObjectWithName(name)))
+        calendar = yield self.calendarUnderTest(
+            txn, name=calendar_name, home=home, status=status
+        )
+        object = yield calendar.calendarObjectWithName(name)
+        returnValue(object)
 
 
     def addressbookHomeUnderTest(self, txn=None, name="home1"):
@@ -921,61 +975,66 @@
     @inlineCallbacks
     def addressbookUnderTest(self, txn=None, name="addressbook", home="home1"):
         """
-        Get the addressbook detailed by C{requirements['home1']['addressbook']}.
+        Get the addressbook detailed by
+        C{requirements['home1']['addressbook']}.
         """
-        returnValue((
-            yield (yield self.addressbookHomeUnderTest(txn=txn, name=home)).addressbookWithName(name)
-        ))
+        home = yield self.addressbookHomeUnderTest(txn=txn, name=home)
+        addressbook = yield home.addressbookWithName(name)
+        returnValue(addressbook)
 
 
     @inlineCallbacks
-    def addressbookObjectUnderTest(self, txn=None, name="1.vcf", addressbook_name="addressbook", home="home1"):
+    def addressbookObjectUnderTest(
+        self, txn=None, name="1.vcf",
+        addressbook_name="addressbook", home="home1",
+    ):
         """
         Get the addressbook detailed by
         C{requirements['home1']['addressbook']['1.vcf']}.
         """
-        returnValue((yield (yield self.addressbookUnderTest(txn=txn, name=addressbook_name, home=home))
-                    .addressbookObjectWithName(name)))
+        addressBook = yield self.addressbookUnderTest(
+            txn=txn, name=addressbook_name, home=home
+        )
+        object = yield addressBook.addressbookObjectWithName(name)
+        returnValue(object)
 
 
-    @inlineCallbacks
     def notificationCollectionUnderTest(self, txn=None, name="home1", status=None, create=False):
         if txn is None:
             txn = self.transactionUnderTest()
-        returnValue((yield txn.notificationsWithUID(name, status=status, create=create)))
+        return txn.notificationsWithUID(name, status=status, create=create)
 
 
-    @inlineCallbacks
     def userRecordWithShortName(self, shortname):
-        record = yield self.directory.recordWithShortName(self.directory.recordType.user, shortname)
-        returnValue(record)
+        return self.directory.recordWithShortName(
+            self.directory.recordType.user, shortname
+        )
 
 
     @inlineCallbacks
     def userUIDFromShortName(self, shortname):
-        record = yield self.directory.recordWithShortName(self.directory.recordType.user, shortname)
+        record = yield self.directory.recordWithShortName(
+            self.directory.recordType.user, shortname
+        )
         returnValue(record.uid if record is not None else None)
 
 
-    @inlineCallbacks
     def addRecordFromFields(self, fields):
         updatedRecord = DirectoryRecord(self.directory, fields)
-        yield self.directory.updateRecords((updatedRecord,), create=True)
+        return self.directory.updateRecords((updatedRecord,), create=True)
 
 
-    @inlineCallbacks
     def removeRecord(self, uid):
-        yield self.directory.removeRecords([uid])
+        return self.directory.removeRecords([uid])
 
 
-    @inlineCallbacks
     def changeRecord(self, record, fieldname, value, directory=None):
         if directory is None:
             directory = self.directory
         fields = record.fields.copy()
         fields[fieldname] = value
         updatedRecord = DirectoryRecord(directory, fields)
-        yield directory.updateRecords((updatedRecord,))
+        return directory.updateRecords((updatedRecord,))
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150306/e8658dda/attachment-0001.html>


More information about the calendarserver-changes mailing list