[CalendarServer-changes] [15285] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 4 11:06:32 PST 2015


Revision: 15285
          http://trac.calendarserver.org//changeset/15285
Author:   cdaboo at apple.com
Date:     2015-11-04 11:06:32 -0800 (Wed, 04 Nov 2015)
Log Message:
-----------
Update all the python and C packages to current versions and fix any issues introduced by that.

Modified Paths:
--------------
    CalendarServer/trunk/bin/_build.sh
    CalendarServer/trunk/calendarserver/accesslog.py
    CalendarServer/trunk/calendarserver/push/util.py
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/calendarserver/tap/profiling.py
    CalendarServer/trunk/calendarserver/tap/test/test_util.py
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/calendarserver/tools/calverify_diff.py
    CalendarServer/trunk/calendarserver/tools/config.py
    CalendarServer/trunk/calendarserver/tools/dkimtool.py
    CalendarServer/trunk/calendarserver/tools/export.py
    CalendarServer/trunk/calendarserver/tools/icalsplit.py
    CalendarServer/trunk/calendarserver/tools/importer.py
    CalendarServer/trunk/calendarserver/tools/managetimezones.py
    CalendarServer/trunk/calendarserver/tools/migrate_verify.py
    CalendarServer/trunk/calendarserver/tools/obliterate.py
    CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
    CalendarServer/trunk/calendarserver/tools/test/test_principals.py
    CalendarServer/trunk/calendarserver/webcal/resource.py
    CalendarServer/trunk/contrib/performance/loadtest/ical.py
    CalendarServer/trunk/contrib/performance/loadtest/population.py
    CalendarServer/trunk/contrib/performance/loadtest/profiles.py
    CalendarServer/trunk/contrib/performance/loadtest/test_ical.py
    CalendarServer/trunk/contrib/performance/sqlusage/requests/httpTests.py
    CalendarServer/trunk/contrib/tools/anonymous_log.py
    CalendarServer/trunk/contrib/tools/harpoon.py
    CalendarServer/trunk/contrib/tools/pg_stats_analysis.py
    CalendarServer/trunk/contrib/tools/protocolanalysis.py
    CalendarServer/trunk/requirements-cs.txt
    CalendarServer/trunk/requirements-twisted-default.txt
    CalendarServer/trunk/requirements-twisted-osx.txt
    CalendarServer/trunk/setup.py
    CalendarServer/trunk/support/_cache_deps
    CalendarServer/trunk/twistedcaldav/accounting.py
    CalendarServer/trunk/twistedcaldav/database.py
    CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipaldb.py
    CalendarServer/trunk/twistedcaldav/localization.py
    CalendarServer/trunk/twistedcaldav/notifications.py
    CalendarServer/trunk/twistedcaldav/sql.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/twistedcaldav/storebridge.py
    CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py
    CalendarServer/trunk/twistedcaldav/test/test_config.py
    CalendarServer/trunk/twistedcaldav/test/test_database.py
    CalendarServer/trunk/twistedcaldav/test/test_multiget.py
    CalendarServer/trunk/twistedcaldav/test/test_sql.py
    CalendarServer/trunk/twistedcaldav/test/test_timezones.py
    CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
    CalendarServer/trunk/twistedcaldav/test/test_xmlutil.py
    CalendarServer/trunk/twistedcaldav/timezones.py
    CalendarServer/trunk/twistedcaldav/timezonestdservice.py
    CalendarServer/trunk/twistedcaldav/upgrade.py
    CalendarServer/trunk/txdav/base/datastore/file.py
    CalendarServer/trunk/txdav/caldav/datastore/index_file.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/mailgateway.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/dkim.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py
    CalendarServer/trunk/txdav/caldav/datastore/sql.py
    CalendarServer/trunk/txdav/caldav/datastore/test/common.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_index_file.py
    CalendarServer/trunk/txdav/carddav/datastore/file.py
    CalendarServer/trunk/txdav/carddav/datastore/index_file.py
    CalendarServer/trunk/txdav/carddav/datastore/sql.py
    CalendarServer/trunk/txdav/carddav/datastore/test/common.py
    CalendarServer/trunk/txdav/carddav/datastore/test/test_index_file.py
    CalendarServer/trunk/txdav/common/datastore/file.py
    CalendarServer/trunk/txdav/who/directory.py
    CalendarServer/trunk/txdav/xml/base.py
    CalendarServer/trunk/txdav/xml/parser_sax.py
    CalendarServer/trunk/txdav/xml/rfc2518.py
    CalendarServer/trunk/txweb2/auth/digest.py
    CalendarServer/trunk/txweb2/dav/fileop.py
    CalendarServer/trunk/txweb2/dav/method/propfind.py
    CalendarServer/trunk/txweb2/dav/test/test_xattrprops.py
    CalendarServer/trunk/txweb2/dav/util.py
    CalendarServer/trunk/txweb2/dav/xattrprops.py
    CalendarServer/trunk/txweb2/static.py
    CalendarServer/trunk/txweb2/test/test_httpauth.py
    CalendarServer/trunk/txweb2/test/test_stream.py

Added Paths:
-----------
    CalendarServer/trunk/calendarserver/test/test_accesslog.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,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/pod2pod-migration:14338-14520
/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/request-socket:14748-14767
/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/sagen/trashcan:14185-14269
/CalendarServer/branches/users/sagen/trashcan-2:14270-14324
/CalendarServer/branches/users/sagen/trashcan-3:14325-14450
/CalendarServer/branches/users/sagen/trashcan-4:14451-14471
/CalendarServer/branches/users/sagen/trashcan-5:14471-14555
/CalendarServer/branches/users/wsanchez/psycopg2cffi:14427-14439
/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,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/pod2pod-migration:14338-14520
/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/cdaboo/update-packages:15273-15284
/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/request-socket:14748-14767
/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/sagen/trashcan:14185-14269
/CalendarServer/branches/users/sagen/trashcan-2:14270-14324
/CalendarServer/branches/users/sagen/trashcan-3:14325-14450
/CalendarServer/branches/users/sagen/trashcan-4:14451-14471
/CalendarServer/branches/users/sagen/trashcan-5:14471-14555
/CalendarServer/branches/users/wsanchez/psycopg2cffi:14427-14439
/CalendarServer/branches/users/wsanchez/transations:5515-5593

Modified: CalendarServer/trunk/bin/_build.sh
===================================================================
--- CalendarServer/trunk/bin/_build.sh	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/bin/_build.sh	2015-11-04 19:06:32 UTC (rev 15285)
@@ -499,13 +499,13 @@
     if [ "${ssl_version}" -ge "${min_ssl_version}" ]; then
       using_system "OpenSSL";
     else
-      local v="0.9.8zf";
+      local v="0.9.8zg";
       local n="openssl";
       local p="${n}-${v}";
 
       # use 'config' instead of 'configure'; 'make' instead of 'jmake'.
       # also pass 'shared' to config to build shared libs.
-      c_dependency -c "config" -m "c69a4a679233f7df189e1ad6659511ec" \
+      c_dependency -c "config" -s "a73005583ba8d5edc3bdcc1f99a1e33ee0ed41f8" \
         -p "make depend" -b "make" \
         "openssl" "${p}" \
         "http://www.openssl.org/source/${p}.tar.gz" "shared";
@@ -587,13 +587,14 @@
       "http://github.com/downloads/libevent/libevent/${p}.tar.gz" \
       ${configure_openssl};
 
-    local v="1.4.20";
+    local v="1.4.24";
     local n="memcached";
     local p="${n}-${v}";
 
-    c_dependency -m "92f702bcb28d7bec8fdf9418360fc062" \
+    c_dependency -s "32a798a37ef782da10a09d74aa1e5be91f2861db" \
       "memcached" "${p}" \
-      "http://www.memcached.org/files/${p}.tar.gz";
+      "http://www.memcached.org/files/${p}.tar.gz" \
+      "--disable-docs";
   fi;
 
 
@@ -725,9 +726,9 @@
   mkdir -p "${py_ve_tools}/junk";
 
   for pkg in             \
-      setuptools-17.0    \
-      pip-7.0.3          \
-      virtualenv-13.0.3  \
+      setuptools-18.5    \
+      pip-7.1.2          \
+      virtualenv-13.1.2  \
   ; do
       local    name="${pkg%-*}";
       local version="${pkg#*-}";

Modified: CalendarServer/trunk/calendarserver/accesslog.py
===================================================================
--- CalendarServer/trunk/calendarserver/accesslog.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/accesslog.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -588,7 +588,7 @@
 
     def __init__(self):
         self.items = {
-            "cpu count"     : psutil.NUM_CPUS if psutil is not None else -1,
+            "cpu count"     : psutil.cpu_count() if psutil is not None else -1,
             "cpu use"       : 0.0,
             "memory used"   : 0,
             "memory percent": 0.0,

Modified: CalendarServer/trunk/calendarserver/push/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/push/util.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/push/util.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -40,7 +40,8 @@
 
     @return: C{str} topic, or empty string if value is not found
     """
-    certData = open(certPath).read()
+    with open(certPath) as f:
+        certData = f.read()
     return getAPNTopicFromX509(crypto.load_certificate(crypto.FILETYPE_PEM, certData))
 
 

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -768,7 +768,7 @@
             else:
                 logID = ""
 
-            if config.ProcessType is not "Utility":
+            if config.ProcessType != "Utility":
                 execName = ""
 
             setproctitle(
@@ -1248,7 +1248,7 @@
                         "-p", str(pool.Port),
                         "-l", pool.BindAddress,
                     ])
-                if config.Memcached.MaxMemory is not 0:
+                if config.Memcached.MaxMemory != 0:
                     memcachedArgv.extend(
                         ["-m", str(config.Memcached.MaxMemory)]
                     )

Modified: CalendarServer/trunk/calendarserver/tap/profiling.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/profiling.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tap/profiling.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -39,12 +39,11 @@
         if self.saveStats:
             p.dump_stats(self.profileOutput)
         else:
-            stream = open(self.profileOutput, 'w')
-            s = pstats.Stats(p, stream=stream)
-            s.strip_dirs()
-            s.sort_stats(-1)
-            s.print_stats()
-            stream.close()
+            with open(self.profileOutput, 'w') as stream:
+                s = pstats.Stats(p, stream=stream)
+                s.strip_dirs()
+                s.sort_stats(-1)
+                s.print_stats()
 
 
 AppProfiler.profilers["cprofile-cpu"] = CProfileCPURunner

Modified: CalendarServer/trunk/calendarserver/tap/test/test_util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/test/test_util.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tap/test/test_util.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -14,17 +14,19 @@
 # limitations under the License.
 ##
 
-from calendarserver.tap.util import (
-    MemoryLimitService, Stepper, verifyTLSCertificate
-)
-from twistedcaldav.util import computeProcessCount
-from twistedcaldav.test.util import TestCase
+from calendarserver.tap.util import MemoryLimitService, Stepper, verifyTLSCertificate, memoryForPID
+
+from twisted.internet.defer import succeed, inlineCallbacks
 from twisted.internet.task import Clock
-from twisted.internet.defer import succeed, inlineCallbacks
 from twisted.python.filepath import FilePath
+
 from twistedcaldav.config import ConfigDict
+from twistedcaldav.test.util import TestCase
+from twistedcaldav.util import computeProcessCount
 
+import os
 
+
 class ProcessCountTestCase(TestCase):
 
     def test_count(self):
@@ -132,7 +134,16 @@
         self.assertEquals(processMonitor.history, ['process #1', 'process #2', 'process #3'])
 
 
+    def test_memoryForPID(self):
+        """
+        Test that L{memoryForPID} returns a valid result.
+        """
 
+        memory = memoryForPID(os.getpid())
+        self.assertNotEqual(memory, 0)
+
+
+
 #
 # Tests for Stepper
 #

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -937,7 +937,7 @@
     @return: Memory used by process in bytes
     @rtype: C{int}
     """
-    memoryInfo = psutil.Process(pid).get_memory_info()
+    memoryInfo = psutil.Process(pid).memory_info()
     return memoryInfo.rss if residentOnly else memoryInfo.vms
 
 
@@ -1524,8 +1524,7 @@
         config.SSLPassPhraseDialog and
         os.path.isfile(config.SSLPassPhraseDialog)
     ):
-        sslPrivKey = open(config.SSLPrivateKey)
-        try:
+        with open(config.SSLPrivateKey) as sslPrivKey:
             keyType = None
             for line in sslPrivKey.readlines():
                 if "-----BEGIN RSA PRIVATE KEY-----" in line:
@@ -1534,8 +1533,6 @@
                 elif "-----BEGIN DSA PRIVATE KEY-----" in line:
                     keyType = "DSA"
                     break
-        finally:
-            sslPrivKey.close()
 
         if keyType is None:
             log.error(

Copied: CalendarServer/trunk/calendarserver/test/test_accesslog.py (from rev 15284, CalendarServer/branches/users/cdaboo/update-packages/calendarserver/test/test_accesslog.py)
===================================================================
--- CalendarServer/trunk/calendarserver/test/test_accesslog.py	                        (rev 0)
+++ CalendarServer/trunk/calendarserver/test/test_accesslog.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -0,0 +1,38 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from twisted.trial.unittest import TestCase
+from calendarserver.accesslog import SystemMonitor
+
+class AccessLog(TestCase):
+    """
+    Tests for L{calendarserver.accesslog}.
+    """
+
+    def test_systemMonitor(self):
+        """
+        L{SystemMonitor} generates the correct data.
+        """
+
+        monitor = SystemMonitor()
+        self.assertNotEqual(monitor.items["cpu count"], 0)
+        self.assertEqual(monitor.items["cpu use"], 0.0)
+
+        monitor.update()
+        self.assertNotEqual(monitor.items["cpu count"], 0)
+
+        monitor.stop()
+        self.assertNotEqual(monitor.items["cpu count"], 0)

Modified: CalendarServer/trunk/calendarserver/tools/calverify_diff.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/calverify_diff.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/calverify_diff.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -24,7 +24,8 @@
 
 def analyze(fname):
 
-    lines = open(os.path.expanduser(fname)).read().splitlines()
+    with open(os.path.expanduser(fname)) as f:
+        lines = f.read().splitlines()
     total = len(lines)
     ctr = 0
     results = {

Modified: CalendarServer/trunk/calendarserver/tools/config.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/config.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/config.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -538,9 +538,8 @@
     @type pidFilename: C{str}
     """
     if os.path.exists(pidFilename):
-        pidFile = open(pidFilename, "r")
-        pid = pidFile.read().strip()
-        pidFile.close()
+        with open(pidFilename, "r") as pidFile:
+            pid = pidFile.read().strip()
         try:
             pid = int(pid)
         except ValueError:

Modified: CalendarServer/trunk/calendarserver/tools/dkimtool.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dkimtool.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/dkimtool.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -40,14 +40,16 @@
     output = key.exportKey()
     lineBreak = False
     if options["key"]:
-        open(options["key"], "w").write(output)
+        with open(options["key"], "w") as f:
+            f.write(output)
     else:
         print(output)
         lineBreak = True
 
     output = key.publickey().exportKey()
     if options["pub-key"]:
-        open(options["pub-key"], "w").write(output)
+        with open(options["pub-key"], "w") as f:
+            f.write(output)
     else:
         if lineBreak:
             print
@@ -70,7 +72,8 @@
         log.publisher.levels.setLogLevelForNamespace("txdav.caldav.datastore.scheduling.ischedule.dkim", LogLevel.debug)
 
     # Parse the HTTP file
-    request = open(options["request"]).read()
+    with open(options["request"]) as f:
+        request = f.read()
     method, uri, headers, stream = _parseRequest(request)
 
     # Setup signing headers
@@ -113,7 +116,8 @@
 @inlineCallbacks
 def _doVerify(options):
     # Parse the HTTP file
-    verify = open(os.path.expanduser(options["verify"])).read()
+    with open(os.path.expanduser(options["verify"])) as f:
+        verify = f.read()
     _method, _uri, headers, body = _parseRequest(verify)
 
     # Check for local public key
@@ -185,7 +189,9 @@
         """
         Do the key lookup using the actual lookup method.
         """
-        return RSA.importKey(open(self.pubkeyfile).read())
+        with open(self.pubkeyfile) as f:
+            data = f.read()
+        return RSA.importKey(data)
 
 
 

Modified: CalendarServer/trunk/calendarserver/tools/export.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/export.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/export.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -346,9 +346,8 @@
                     comp.addComponent(sub)
 
         filename = os.path.join(dirname, "{}_{}.ics".format(homeUID, calendar.name()))
-        fileobj = open(filename, 'wb')
-        fileobj.write(comp.getTextWithTimezones(True))
-        fileobj.close()
+        with open(filename, 'wb') as fileobj:
+            fileobj.write(comp.getTextWithTimezones(True))
 
 
 

Modified: CalendarServer/trunk/calendarserver/tools/icalsplit.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/icalsplit.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/icalsplit.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -29,11 +29,8 @@
     converting a monolithic iCalendar object into a set of objects
     that comply with CalDAV's requirements on resources.
     """
-    inputFile = open(inputFileName)
-    try:
+    with open(inputFileName) as inputFile:
         calendar = iComponent.fromStream(inputFile)
-    finally:
-        inputFile.close()
 
     assert calendar.name() == "VCALENDAR"
 

Modified: CalendarServer/trunk/calendarserver/tools/importer.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/importer.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/importer.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -362,9 +362,8 @@
                 for filename in os.listdir(dirname):
                     fullpath = os.path.join(dirname, filename)
                     print("Importing {}".format(fullpath))
-                    fileobj = open(fullpath, 'r')
-                    component = Component.allFromStream(fileobj)
-                    fileobj.close()
+                    with open(fullpath, 'r') as fileobj:
+                        component = Component.allFromStream(fileobj)
                     yield importCollectionComponent(self.store, component)
 
             else:

Modified: CalendarServer/trunk/calendarserver/tools/managetimezones.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/managetimezones.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/managetimezones.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -85,7 +85,8 @@
 
     # Get the version from the Makefile
     try:
-        makefile = open(os.path.join(zonedir, "Makefile")).read()
+        with open(os.path.join(zonedir, "Makefile")) as f:
+            makefile = f.read()
         lines = makefile.splitlines()
         for line in lines:
             if line.startswith("VERSION="):

Modified: CalendarServer/trunk/calendarserver/tools/migrate_verify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/migrate_verify.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/migrate_verify.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -161,36 +161,36 @@
 
         self.output.write("-- Reading data file: %s\n" % (self.options["data"]))
 
-        datafile = open(os.path.expanduser(self.options["data"]))
-        total = 0
-        invalidGUIDs = set()
-        for line in datafile:
-            line = line.strip()
-            total += 1
-            segments = line.split("/")
-            while segments and segments[0] != "__uids__":
-                segments.pop(0)
-            if segments and len(segments) >= 6:
-                guid = segments[3]
-                calendar = segments[4]
-                resource = segments[5]
+        with open(os.path.expanduser(self.options["data"])) as datafile:
+            total = 0
+            invalidGUIDs = set()
+            for line in datafile:
+                line = line.strip()
+                total += 1
+                segments = line.split("/")
+                while segments and segments[0] != "__uids__":
+                    segments.pop(0)
+                if segments and len(segments) >= 6:
+                    guid = segments[3]
+                    calendar = segments[4]
+                    resource = segments[5]
 
-                if calendar == "inbox":
-                    self.ignoreInbox += 1
-                    invalidGUIDs.add(guid)
-                elif calendar == "dropbox":
-                    self.ignoreDropbox += 1
-                    invalidGUIDs.add(guid)
-                elif len(segments) > 6:
+                    if calendar == "inbox":
+                        self.ignoreInbox += 1
+                        invalidGUIDs.add(guid)
+                    elif calendar == "dropbox":
+                        self.ignoreDropbox += 1
+                        invalidGUIDs.add(guid)
+                    elif len(segments) > 6:
+                        self.badPaths.append(line)
+                        invalidGUIDs.add(guid)
+                    else:
+                        self.pathsByGUID.setdefault(guid, {}).setdefault(calendar, set()).add(resource)
+                        self.validPaths += 1
+                else:
+                    if segments and len(segments) >= 4:
+                        invalidGUIDs.add(segments[3])
                     self.badPaths.append(line)
-                    invalidGUIDs.add(guid)
-                else:
-                    self.pathsByGUID.setdefault(guid, {}).setdefault(calendar, set()).add(resource)
-                    self.validPaths += 1
-            else:
-                if segments and len(segments) >= 4:
-                    invalidGUIDs.add(segments[3])
-                self.badPaths.append(line)
 
         # Remove any invalid GUIDs that actuall were valid
         invalidGUIDs = [pguid for pguid in invalidGUIDs if pguid not in self.pathsByGUID]

Modified: CalendarServer/trunk/calendarserver/tools/obliterate.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/obliterate.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/obliterate.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -271,7 +271,8 @@
                 self.output.write("%s is not a valid file\n" % (self.options["data"],))
                 raise ConfigError
 
-            uuids = open(self.options["data"]).read().split()
+            with open(self.options["data"]) as f:
+                uuids = f.read().split()
         else:
             self.output.write("One of --data or --uuid must be specified\n")
             raise ConfigError

Modified: CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_gateway.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/test/test_gateway.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -69,9 +69,8 @@
 
         testRoot = os.path.join(os.path.dirname(__file__), "gateway")
         templateName = os.path.join(testRoot, "caldavd.plist")
-        templateFile = open(templateName)
-        template = templateFile.read()
-        templateFile.close()
+        with open(templateName) as templateFile:
+            template = templateFile.read()
 
         databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid()))
         newConfig = template % {

Modified: CalendarServer/trunk/calendarserver/tools/test/test_principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_principals.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/tools/test/test_principals.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -37,9 +37,8 @@
 
         testRoot = os.path.join(os.path.dirname(__file__), "principals")
         templateName = os.path.join(testRoot, "caldavd.plist")
-        templateFile = open(templateName)
-        template = templateFile.read()
-        templateFile.close()
+        with open(templateName) as templateFile:
+            template = templateFile.read()
 
         databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid()))
         newConfig = template % {

Modified: CalendarServer/trunk/calendarserver/webcal/resource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webcal/resource.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/calendarserver/webcal/resource.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -131,11 +131,8 @@
         # If we don't have a cached template, load it up.
         #
         if not hasattr(self, cacheAttr):
-            templateFile = open(templateFileName)
-            try:
+            with open(templateFileName) as templateFile:
                 htmlContent = templateFile.read()
-            finally:
-                templateFile.close()
 
             if debug:
                 # Don't cache
@@ -201,6 +198,19 @@
 
 
 try:
+    from osx.utils import CFTimeZoneRef
+
+    def lookupSystemTimezone():
+        try:
+            return CFTimeZoneRef.defaultTimeZoneName()
+        except:
+            return ""
+
+except ImportError:
+    def lookupSystemTimezone():
+        return ""
+
+try:
     from Foundation import NSTimeZone
 
     def lookupSystemTimezone():

Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -167,9 +167,8 @@
         """
         path = self.serializePath()
         if path and os.path.exists(path):
-            f = open(path)
-            comp = Component.fromString(f.read())
-            f.close()
+            with open(path) as f:
+                comp = Component.fromString(f.read())
             return comp
         else:
             return None
@@ -185,9 +184,8 @@
             if component is None:
                 os.remove(path)
             else:
-                f = open(path, "w")
-                f.write(str(component))
-                f.close()
+                with open(path, "w") as f:
+                    f.write(str(component))
         self.uid = component.resourceUID() if component is not None else None
 
 
@@ -1332,7 +1330,8 @@
         }
 
         # Write JSON data
-        json.dump(data, open(os.path.join(path, "index.json"), "w"), indent=2)
+        with open(os.path.join(path, "index.json"), "w") as f:
+            json.dump(data, f, indent=2)
 
 
     def deserialize(self):
@@ -1349,7 +1348,8 @@
 
         # Parse JSON data for calendars
         try:
-            data = json.load(open(os.path.join(path, "index.json")))
+            with open(os.path.join(path, "index.json")) as f:
+                data = json.load(f)
         except IOError:
             return
 

Modified: CalendarServer/trunk/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/population.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/performance/loadtest/population.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -407,7 +407,8 @@
 
         # Load parameters from config
         if "thresholdsPath" in params:
-            jsondata = json.load(open(params["thresholdsPath"]))
+            with open(params["thresholdsPath"]) as f:
+                jsondata = json.load(f)
         elif "thresholds" in params:
             jsondata = params["thresholds"]
         else:
@@ -423,7 +424,8 @@
         self._fields.extend(self._fields_extend)
 
         if "benchmarksPath" in params:
-            self.benchmarks = json.load(open(params["benchmarksPath"]))
+            with open(params["benchmarksPath"]) as f:
+                self.benchmarks = json.load(f)
         else:
             self.benchmarks = {}
 

Modified: CalendarServer/trunk/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/performance/loadtest/profiles.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -915,7 +915,8 @@
 
         # Load parameters from config
         if "thresholdsPath" in params:
-            jsondata = json.load(open(params["thresholdsPath"]))
+            with open(params["thresholdsPath"]) as f:
+                jsondata = json.load(f)
         elif "thresholds" in params:
             jsondata = params["thresholds"]
         else:

Modified: CalendarServer/trunk/contrib/performance/loadtest/test_ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/performance/loadtest/test_ical.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -1540,7 +1540,9 @@
         self.assertTrue(os.path.exists(indexPath))
         def _normDict(d):
             return dict([(k, sorted(v, key=lambda x: x["changeToken" if k == "calendars" else "url"]) if v else None,) for k, v in d.items()])
-        self.assertEqual(_normDict(json.loads(open(indexPath).read())), _normDict(json.loads("""{
+        with open(indexPath) as f:
+            jdata = f.read()
+        self.assertEqual(_normDict(json.loads(jdata)), _normDict(json.loads("""{
   "calendars": [
     {
       "changeToken": "123",
@@ -1597,11 +1599,15 @@
 
         event1Path = os.path.join(clientPath, "calendar", "1.ics")
         self.assertTrue(os.path.exists(event1Path))
-        self.assertEqual(open(event1Path).read(), cal1)
+        with open(event1Path) as f:
+            data = f.read()
+        self.assertEqual(data, cal1)
 
         event2Path = os.path.join(clientPath, "inbox", "i1.ics")
         self.assertTrue(os.path.exists(event2Path))
-        self.assertEqual(open(event2Path).read(), cal2)
+        with open(event2Path) as f:
+            data = f.read()
+        self.assertEqual(data, cal2)
 
 
     def test_deserialization(self):
@@ -1642,7 +1648,8 @@
         clientPath = os.path.join(self.client.serializePath, "user91-OS_X_10.6")
         os.mkdir(clientPath)
         indexPath = os.path.join(clientPath, "index.json")
-        open(indexPath, "w").write("""{
+        with open(indexPath, "w") as f:
+            f.write("""{
   "calendars": [
     {
       "changeToken": "321",
@@ -1699,10 +1706,12 @@
 
         os.mkdir(os.path.join(clientPath, "calendar"))
         event1Path = os.path.join(clientPath, "calendar", "2.ics")
-        open(event1Path, "w").write(cal1)
+        with open(event1Path, "w") as f:
+            f.write(cal1)
         os.mkdir(os.path.join(clientPath, "inbox"))
         event1Path = os.path.join(clientPath, "inbox", "i2.ics")
-        open(event1Path, "w").write(cal2)
+        with open(event1Path, "w") as f:
+            f.write(cal2)
 
         self.client.deserialize()
 

Modified: CalendarServer/trunk/contrib/performance/sqlusage/requests/httpTests.py
===================================================================
--- CalendarServer/trunk/contrib/performance/sqlusage/requests/httpTests.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/performance/sqlusage/requests/httpTests.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -67,7 +67,8 @@
         """
         Clear the server's SQL log file.
         """
-        open(self.logFilePath, "w").write("")
+        with open(self.logFilePath, "w") as f:
+            f.write("")
 
 
     def doRequest(self):
@@ -91,7 +92,8 @@
             return float(line[pos + 2:])
 
         # Need to skip over stats that are unlabeled
-        data = open(self.logFilePath).read()
+        with open(self.logFilePath) as f:
+            data = f.read()
         lines = data.splitlines()
         offset = 0
         while True:

Modified: CalendarServer/trunk/contrib/tools/anonymous_log.py
===================================================================
--- CalendarServer/trunk/contrib/tools/anonymous_log.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/tools/anonymous_log.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -55,7 +55,10 @@
             print("Exception: %s for %s" % (e, line,))
             raise
 
+        finally:
+            f.close()
 
+
     def anonymizeLine(self, line):
 
         startPos = line.find("- ")

Modified: CalendarServer/trunk/contrib/tools/harpoon.py
===================================================================
--- CalendarServer/trunk/contrib/tools/harpoon.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/tools/harpoon.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -41,12 +41,14 @@
 
     pidDir = os.path.join(PROCDIR, pidString)
     statsFile = os.path.join(pidDir, "stat")
-    statLine = open(statsFile).read()
+    with open(statsFile) as f:
+        statLine = f.read()
     stats = statLine.split()
     vsize = int(stats[22])
     cmdFile = os.path.join(pidDir, "cmdline")
     if os.path.exists(cmdFile):
-        cmdLine = open(cmdFile).read().split('\x00')
+        with open(cmdFile) as f:
+            cmdLine = f.read().split('\x00')
         if cmdLine[0].startswith(PYTHON):
             for arg in cmdLine[1:]:
                 if arg.startswith(CMDARG):

Modified: CalendarServer/trunk/contrib/tools/pg_stats_analysis.py
===================================================================
--- CalendarServer/trunk/contrib/tools/pg_stats_analysis.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/tools/pg_stats_analysis.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -160,6 +160,8 @@
         if line.startswith("---"):
             break
 
+    f.close()
+
     entries = []
     for line in f:
         bits = line.split("|")

Modified: CalendarServer/trunk/contrib/tools/protocolanalysis.py
===================================================================
--- CalendarServer/trunk/contrib/tools/protocolanalysis.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/contrib/tools/protocolanalysis.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -439,6 +439,9 @@
             print("Failed to process line:\n%s" % (line,))
             raise
 
+        finally:
+            f.close()
+
         # Average various items
         self.averagedHourlyByMethodTime.clear()
         for method, hours in self.hourlyByMethodTime.iteritems():

Modified: CalendarServer/trunk/requirements-cs.txt
===================================================================
--- CalendarServer/trunk/requirements-cs.txt	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/requirements-cs.txt	2015-11-04 19:06:32 UTC (rev 15285)
@@ -4,20 +4,20 @@
 
 --editable .  # calendarserver
 
-    zope.interface==4.1.2
-	    setuptools==17.0
+    zope.interface==4.1.3
+	    setuptools==18.5
 
-    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15263#egg=twextpy
-        cffi==1.1.0
-            pycparser==2.13
+    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15283#egg=twextpy
+        cffi==1.3.0
+            pycparser==2.14
         #twisted
 
         # [LDAP] extra
-            python-ldap==2.4.19
+            python-ldap==2.4.22
                 #setuptools
 
         # [DAL] extra
-              sqlparse==0.1.14  # Compat issue in 0.1.15; fix before updating
+              sqlparse==0.1.18
 
         # [OpenDirectory] extra
             #pyobjc-framework-OpenDirectory  # Use system module
@@ -31,10 +31,10 @@
     --editable svn+http://svn.calendarserver.org/repository/calendarserver/PyKerberos/trunk@15140#egg=kerberos
 
     --editable svn+http://svn.calendarserver.org/repository/calendarserver/PyCalendar/trunk@15020#egg=pycalendar
-    python-dateutil==1.5  # Note: v2.0+ is for Python 3
-    pytz==2015.4
+    python-dateutil==2.4.2
+    pytz==2015.7
 
-    psutil==2.2.1
-    setproctitle==1.1.8
+    psutil==3.2.2
+    setproctitle==1.1.9
     # xattr==0.7.5  # Only needed for upgrades from ancient versions.  Added in _cache_deps.
         #cffi

Modified: CalendarServer/trunk/requirements-twisted-default.txt
===================================================================
--- CalendarServer/trunk/requirements-twisted-default.txt	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/requirements-twisted-default.txt	2015-11-04 19:06:32 UTC (rev 15285)
@@ -12,13 +12,13 @@
     #pyOpenSSL
     service_identity==14.0.0
         characteristic==14.3.0
-        pyasn1==0.1.7
-        pyasn1-modules==0.0.5
+        pyasn1==0.1.9
+        pyasn1-modules==0.0.8
         #pyOpenSSL
     pycrypto==2.6.1
 
-    pyOpenSSL==0.14
-        cryptography==0.9
+    pyOpenSSL==0.15.1
+        cryptography==1.1
         	idna
             #pyasn1
             #cffi
@@ -26,4 +26,4 @@
             ipaddress
             #setuptools==17.0
             #six
-        six==1.9.0
+        six==1.10.0

Modified: CalendarServer/trunk/requirements-twisted-osx.txt
===================================================================
--- CalendarServer/trunk/requirements-twisted-osx.txt	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/requirements-twisted-osx.txt	2015-11-04 19:06:32 UTC (rev 15285)
@@ -2,13 +2,13 @@
 # Twisted dependency for OS X systems (uses pySecureTransport).
 ##
 
-Twisted==15.2.1
+Twisted==15.4.0
     #zope.interface
     pycrypto==2.6.1
 
     --editable svn+http://svn.calendarserver.org/repository/calendarserver/OSXFrameworks/trunk@15238#egg=osxframeworks
-        #cffi==1.1.0
-        #    pycparser==2.13
+        #cffi==1.3.0
+        #    pycparser==2.14
 
     --editable svn+http://svn.calendarserver.org/repository/calendarserver/PySecureTransport/trunk@15229#egg=pysecuretransport
 

Modified: CalendarServer/trunk/setup.py
===================================================================
--- CalendarServer/trunk/setup.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/setup.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -322,7 +322,7 @@
 install_requirements = [
     # Core frameworks
     "zope.interface",
-    "Twisted>=15.2.1",
+    "Twisted>=15.4.0",
     "twextpy",
 
     # Security frameworks
@@ -332,7 +332,7 @@
     # Data store
     "xattr",
     "twextpy[DAL]",
-    "sqlparse>=0.1.11",
+    "sqlparse",
 
     # Calendar
     "python-dateutil",
@@ -351,7 +351,7 @@
     ])
 else:
     install_requirements.extend([
-        "pyOpenSSL>=0.14",    # also for Twisted
+        "pyOpenSSL>=0.15.1",    # also for Twisted
         "service_identity",   # for Twisted
     ])
 
@@ -500,9 +500,8 @@
                 else:
                     script.append(line)
 
-            newScript = open(scriptPath, "w")
-            newScript.write("\n".join(script))
-            newScript.close()
+            with open(scriptPath, "w") as newScript:
+                newScript.write("\n".join(script))
 
 
 #

Modified: CalendarServer/trunk/support/_cache_deps
===================================================================
--- CalendarServer/trunk/support/_cache_deps	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/support/_cache_deps	2015-11-04 19:06:32 UTC (rev 15285)
@@ -39,9 +39,9 @@
 mkdir -p "${wd}/.develop/tools";
 
 for pkg in             \
-    setuptools-17.0    \
-    pip-7.0.3          \
-    virtualenv-13.0.3  \
+    setuptools-18.5    \
+    pip-7.1.2          \
+    virtualenv-13.1.2  \
 ; do
        name="${pkg%-*}";
     version="${pkg#*-}";

Modified: CalendarServer/trunk/twistedcaldav/accounting.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/accounting.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/accounting.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -134,11 +134,8 @@
         #
         # Now write out the data to the log file
         #
-        logFile = open(os.path.join(logRoot, logFilename), "a")
-        try:
+        with open(os.path.join(logRoot, logFilename), "a") as logFile:
             logFile.write(data)
-        finally:
-            logFile.close()
 
         return logFilename
 

Modified: CalendarServer/trunk/twistedcaldav/database.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/database.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/database.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -23,6 +23,7 @@
 ]
 
 import thread
+import threading
 
 try:
     from txdav.base.datastore.subpostgres import postgres
@@ -41,28 +42,43 @@
 
 
 
-class ConnectionClosingThreadPool(ThreadPool):
+class ConnectionCloseThread(threading.Thread):
     """
-    A ThreadPool that closes connections for each worker thread
+    An L{Thread} that closes its DB connection when it has finished running.
     """
 
-    def _worker(self):
-        log.debug("Starting ADBAPI thread: %s" % (thread.get_ident(),))
-        ThreadPool._worker(self)
-        self._closeConnection()
+    def __init__(self, group=None, target=None, name=None,
+                 args=(), kwargs=None, verbose=None):
 
+        if target is not None:
+            self._realTarget = target
+            target = self.targetWithConnectionClose
+        super(ConnectionCloseThread, self).__init__(group=group, target=target, name=name, args=args, kwargs=kwargs, verbose=verbose)
 
-    def _closeConnection(self):
 
-        tid = thread.get_ident()
-        log.debug("Closing ADBAPI thread: %s" % (tid,))
+    def targetWithConnectionClose(self, *args, **kwargs):
+        self._realTarget(*args, **kwargs)
+        if hasattr(self, "_db_close"):
+            self._db_close()
 
-        conn = self.pool.connections.get(tid)
-        self.pool._close(conn)
-        del self.pool.connections[tid]
 
 
+class ConnectionClosingThreadPool(ThreadPool):
+    """
+    A L{ThreadPool} that closes connections for each worker thread when stopped.
+    """
 
+    threadFactory = ConnectionCloseThread
+
+    def stop(self):
+        for tid, conn in self.pool.connections.items():
+            for thread in self.threads:
+                if thread.ident == tid:
+                    thread._db_close = lambda : self.pool.disconnect(conn)
+        ThreadPool.stop(self)
+
+
+
 class AbstractADBAPIDatabase(object):
     """
     A generic SQL database.

Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipaldb.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipaldb.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipaldb.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -89,7 +89,9 @@
         self.assertEqual(membersA, set(("B", "C", "D",)))
         self.assertEqual(membershipsB, set(("A",)))
 
+        db.close()
 
+
     @inlineCallbacks
     def test_normalDBNonAscii(self):
 
@@ -105,7 +107,9 @@
         self.assertEqual(membersA, set(("B", "C", "D",)))
         self.assertEqual(membershipsB, set((principalID,)))
 
+        db.close()
 
+
     @inlineCallbacks
     def test_DBIndexed(self):
 
@@ -114,7 +118,9 @@
         db = ProxySqliteDB(db_path)
         self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set(("GROUPNAMES", "MEMBERS")))
 
+        db.close()
 
+
     @inlineCallbacks
     def test_OldDB(self):
 
@@ -123,7 +129,9 @@
         db = self.old_ProxyDB(db_path)
         self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set())
 
+        db.close()
 
+
     @inlineCallbacks
     def test_DBUpgrade(self):
 
@@ -150,7 +158,6 @@
         self.assertEqual(membershipsB, set(("A",)))
         self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set(("GROUPNAMES", "MEMBERS")))
         db.close()
-        db = None
 
 
     @inlineCallbacks
@@ -253,7 +260,9 @@
 
             yield db.clean()
 
+            db.close()
 
+
     @inlineCallbacks
     def test_cachingDBRemove(self):
 
@@ -297,7 +306,9 @@
 
             yield db.clean()
 
+            db.close()
 
+
     @inlineCallbacks
     def test_cachingDBRemoveSpecial(self):
 
@@ -333,7 +344,9 @@
 
             yield db.clean()
 
+            db.close()
 
+
     @inlineCallbacks
     def test_cachingDBInsertUncached(self):
 
@@ -365,8 +378,10 @@
 
             yield db.clean()
 
+            db.close()
 
 
+
 class ProxyPrincipalDBPostgreSQL (twistedcaldav.test.util.TestCase):
     """
     Directory service provisioned principals.

Modified: CalendarServer/trunk/twistedcaldav/localization.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/localization.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/localization.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -27,9 +27,8 @@
 from pycalendar.duration import Duration
 
 try:
-    from Foundation import (
-        NSPropertyListImmutable, NSPropertyListSerialization, NSData, NSLocale
-    )
+    from osx.corefoundation import CFError
+    from osx.utils import CFLocaleRef, CFDataRef, CFPropertyListRef
     foundationImported = True
 except ImportError:
     foundationImported = False
@@ -444,16 +443,18 @@
             return
 
     # Parse the binary plist .strings file:
-    parser = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_
-    data = NSData.dataWithContentsOfMappedFile_(src)
-    strings, format, error = parser(data, NSPropertyListImmutable, None, None)
-    if error:
+    with open(src) as f:
+        data = f.read()
+    data = CFDataRef.fromString(data)
+    try:
+        parsed = CFPropertyListRef.createFromData(data)
+        strings = parsed.toDict()
+    except CFError as error:
         raise ParseError(error)
 
     # The format of GNUtext MO files is described here:
     # http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html
 
-    strings = dict(strings)
     originals = strings.keys()
     originals.sort()
 
@@ -538,7 +539,7 @@
         return config.Localization.Language
 
     try:
-        language = NSLocale.preferredLanguages()[0]
+        language = CFLocaleRef.preferredLanguages()[0]
         language = _remapLanguageCode(language)
     except:
         language = "en"

Modified: CalendarServer/trunk/twistedcaldav/notifications.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/notifications.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/notifications.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -156,7 +156,10 @@
         db_filename = os.path.join(self.resource.fp.path, NotificationsDatabase.db_basename)
         super(NotificationsDatabase, self).__init__(db_filename, True, autocommit=True)
 
+        self.resource._txn.postCommit(self._db_close)
+        self.resource._txn.postAbort(self._db_close)
 
+
     def allRecords(self):
 
         records = self._db_execute("select * from NOTIFICATIONS")

Modified: CalendarServer/trunk/twistedcaldav/sql.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sql.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/sql.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -192,17 +192,17 @@
         # want other processes to get stomped on or stomp on us.
         old_isolation = self._db_connection.isolation_level
         self._db_connection.isolation_level = None
-        q.execute("begin exclusive transaction")
+        try:
+            q.execute("begin exclusive transaction")
 
-        # We re-check whether the schema table is present again AFTER we've got an exclusive
-        # lock as some other server process may have snuck in and already created it
-        # before we got the lock, or whilst we were waiting for it.
-        if not self._test_schema_table(q):
-            self._db_init_schema_table(q)
-            self._db_init_data_tables(q)
-            self._db_recreate(False)
+            # We re-check whether the schema table is present again AFTER we've got an exclusive
+            # lock as some other server process may have snuck in and already created it
+            # before we got the lock, or whilst we were waiting for it.
+            if not self._test_schema_table(q):
+                self._db_init_schema_table(q)
+                self._db_init_data_tables(q)
+                self._db_recreate(False)
 
-        try:
             q.execute("commit")
         except DatabaseError:
             pass

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -1210,7 +1210,8 @@
         parser = NoUnicodePlistParser()
         configDict = None
         try:
-            configDict = parser.parse(open(filename))
+            with open(filename) as f:
+                configDict = parser.parse(f)
         except (IOError, OSError):
             log.error("Configuration file does not exist or is inaccessible: %s" % (filename,))
             raise ConfigurationError("Configuration file does not exist or is inaccessible: %s" % (filename,))

Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -25,7 +25,6 @@
 from twext.python.log import Logger
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue, maybeDeferred
 from twisted.internet.protocol import Protocol
-from twisted.python.hashlib import md5
 from twisted.python.util import FancyEqMixin
 from twistedcaldav import customxml, carddavxml, caldavxml, ical
 from twistedcaldav.caldavxml import (
@@ -657,7 +656,7 @@
 
             try:
                 # Create a new name if one was not provided
-                name = md5(str(index) + component.resourceUID() + str(time.time()) + request.path).hexdigest() + self.resourceSuffix()
+                name = hashlib.md5(str(index) + component.resourceUID() + str(time.time()) + request.path).hexdigest() + self.resourceSuffix()
 
                 # Get a resource for the new item
                 newchildURL = joinURL(request.path, name)
@@ -3342,7 +3341,7 @@
 
             try:
                 # Create a new name if one was not provided
-                name = md5(str(index) + component.resourceUID() + str(time.time()) + request.path).hexdigest() + self.resourceSuffix()
+                name = hashlib.md5(str(index) + component.resourceUID() + str(time.time()) + request.path).hexdigest() + self.resourceSuffix()
 
                 # Get a resource for the new item
                 newchildURL = joinURL(request.path, name)

Modified: CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -85,7 +85,8 @@
         calendar = yield self.calendarUnderTest(name="calendar", home=record.uid)
         for f in os.listdir(self.holidays_dir):
             if f.endswith(".ics"):
-                component = Component.fromString(open(os.path.join(self.holidays_dir, f)).read())
+                with open(os.path.join(self.holidays_dir, f)) as fin:
+                    component = Component.fromString(fin.read())
                 yield calendar._createCalendarObjectWithNameInternal(f, component, internal_state=ComponentUpdateState.RAW)
         yield self.commit()
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_config.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_config.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -136,7 +136,8 @@
         TestCase.setUp(self)
         config.setProvider(PListConfigProvider(DEFAULT_CONFIG))
         self.testConfig = self.mktemp()
-        open(self.testConfig, "w").write(testConfig)
+        with open(self.testConfig, "w") as f:
+            f.write(testConfig)
 
 
     def tearDown(self):
@@ -565,10 +566,12 @@
         config.setProvider(PListConfigProvider(DEFAULT_CONFIG))
 
         self.testInclude = self.mktemp()
-        open(self.testInclude, "w").write(testConfigInclude)
+        with open(self.testInclude, "w") as f:
+            f.write(testConfigInclude)
 
         self.testMaster = self.mktemp()
-        open(self.testMaster, "w").write(testConfigMaster % (self.testInclude,))
+        with open(self.testMaster, "w") as f:
+            f.write(testConfigMaster % (self.testInclude,))
 
         config.load(self.testMaster)
         self.assertEquals(config.HTTPPort, 9008)
@@ -630,10 +633,12 @@
 
         self.testIncludeRoot = self.mktemp()
         self.testInclude = self.testIncludeRoot + "." + socket.getfqdn()
-        open(self.testInclude, "w").write(testConfigInclude)
+        with open(self.testInclude, "w") as f:
+            f.write(testConfigInclude)
 
         self.testMaster = self.mktemp()
-        open(self.testMaster, "w").write(testConfigMaster % (self.testIncludeRoot,))
+        with open(self.testMaster, "w") as f:
+            f.write(testConfigMaster % (self.testIncludeRoot,))
 
         config.load(self.testMaster)
         self.assertEquals(config.HTTPPort, 9008)
@@ -695,10 +700,12 @@
 
         self.testIncludeRoot = self.mktemp()
         self.testInclude = self.testIncludeRoot + "." + socket.gethostbyname(socket.getfqdn())
-        open(self.testInclude, "w").write(testConfigInclude)
+        with open(self.testInclude, "w") as f:
+            f.write(testConfigInclude)
 
         self.testMaster = self.mktemp()
-        open(self.testMaster, "w").write(testConfigMaster % (self.testIncludeRoot,))
+        with open(self.testMaster, "w") as f:
+            f.write(testConfigMaster % (self.testIncludeRoot,))
 
         config.load(self.testMaster)
         self.assertEquals(config.HTTPPort, 9008)

Modified: CalendarServer/trunk/twistedcaldav/test/test_database.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_database.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_database.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -124,6 +124,7 @@
         self.assertFalse(db.initialized)
         yield db.open()
         self.assertTrue(db.initialized)
+        db.close()
 
 
     @inlineCallbacks
@@ -154,6 +155,7 @@
         self.assertEqual(items, (("FOO", "BAR"),))
         items = (yield db.queryList("SELECT * from TESTTYPE"))
         self.assertEqual(items, ("FOO",))
+        db.close()
 
 
     @inlineCallbacks
@@ -189,6 +191,7 @@
         yield self.inlineCallbackRaises(Database.TestDBRecreateUpgrade.RecreateDBException, db.open)
         items = (yield db.query("SELECT * from TESTTYPE"))
         self.assertEqual(items, ())
+        db.close()
 
 
     @inlineCallbacks
@@ -215,6 +218,7 @@
         yield db.open()
         items = (yield db.query("SELECT * from TESTTYPE"))
         self.assertEqual(items, (("FOO", "BAR"),))
+        db.close()
 
 
     @inlineCallbacks
@@ -235,3 +239,4 @@
         yield db.open()
         items = (yield db.query("SELECT * from TESTTYPE"))
         self.assertEqual(items, (("FOO", "BAR"),))
+        db.close()

Modified: CalendarServer/trunk/twistedcaldav/test/test_multiget.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_multiget.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_multiget.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -161,8 +161,8 @@
 
         # Now forcibly corrupt one piece of calendar data
         calendar_path = os.path.join(self.docroot, "calendar_multiget_events/", "bad.ics")
-        f = open(calendar_path, "w")
-        f.write("""BEGIN:VCALENDAR
+        with open(calendar_path, "w") as f:
+            f.write("""BEGIN:VCALENDAR
 CALSCALE:GREGORIAN
 PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
 VERSION:2.0
@@ -173,7 +173,6 @@
 DTSTAMP:20020101T121212Z
 END:VCALENDAR
 """.replace("\n", "\r\n"))
-        f.close
 
         okuids = ["good", ]
         baduids = ["bad", ]

Modified: CalendarServer/trunk/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_sql.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_sql.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -107,6 +107,7 @@
         self.assertFalse(hasattr(db, "_db_connection"))
         self.assertTrue(db._db() is not None)
         self.assertTrue(db._db_connection is not None)
+        db._db_close()
 
 
     def test_connect_autocommit(self):
@@ -117,6 +118,7 @@
         self.assertFalse(hasattr(db, "_db_connection"))
         self.assertTrue(db._db() is not None)
         self.assertTrue(db._db_connection is not None)
+        db._db_close()
 
 
     def test_readwrite(self):
@@ -129,6 +131,7 @@
         q = db._db().execute("SELECT * from TESTTYPE")
         items = [i for i in q.fetchall()]
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()
 
 
     def test_readwrite_autocommit(self):
@@ -140,6 +143,7 @@
         q = db._db().execute("SELECT * from TESTTYPE")
         items = [i for i in q.fetchall()]
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()
 
 
     def test_readwrite_cursor(self):
@@ -150,6 +154,7 @@
         db._db_execute("INSERT into TESTTYPE (KEY, VALUE) values (:1, :2)", "FOO", "BAR")
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()
 
 
     def test_readwrite_cursor_autocommit(self):
@@ -160,6 +165,7 @@
         db._db_execute("INSERT into TESTTYPE (KEY, VALUE) values (:1, :2)", "FOO", "BAR")
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()
 
 
     def test_readwrite_rollback(self):
@@ -171,6 +177,7 @@
         db._db_rollback()
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [])
+        db._db_close()
 
 
     def test_close(self):
@@ -194,6 +201,7 @@
                 try:
                     db = SQL.TestDBPauseInInit(dbname)
                     db._db()
+                    db._db_close()
                     self.result = True
                 except:
                     self.result = False
@@ -224,6 +232,7 @@
         self.assertRaises(SQL.TestDBRecreateUpgrade.RecreateDBException, db._db)
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [])
+        db._db_close()
 
 
     def test_version_upgrade_persistent(self):
@@ -249,6 +258,7 @@
         self.assertTrue(db._db() is not None)
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()
 
 
     def test_version_upgrade_persistent_add_index(self):
@@ -268,3 +278,4 @@
         self.assertTrue(db._db() is not None)
         items = db._db_execute("SELECT * from TESTTYPE")
         self.assertEqual(items, [("FOO", "BAR")])
+        db._db_close()

Modified: CalendarServer/trunk/twistedcaldav/test/test_timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -325,3 +325,5 @@
 
         self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
         self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
+
+    test_copyPackage_Concurrency.skip = "This tests needs to use separate processes rather than threads to work properly as the FilesystemLock object is process-based "

Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -1502,6 +1502,7 @@
         )
 
         yield txn.commit()
+        sqliteProxyService.close()
 
 
     def test_resourcesXML(self):

Modified: CalendarServer/trunk/twistedcaldav/test/test_xmlutil.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_xmlutil.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/test/test_xmlutil.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -85,7 +85,8 @@
     def _checkXML(self, node, data):
         xmlfile = self.mktemp()
         writeXML(xmlfile, node)
-        newdata = open(xmlfile).read()
+        with open(xmlfile) as f:
+            newdata = f.read()
         self.assertEqual(newdata, data)
 
 

Modified: CalendarServer/trunk/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/timezones.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/timezones.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -102,7 +102,8 @@
     @staticmethod
     def getTZVersion(dbpath):
         try:
-            return open(os.path.join(dbpath, "version.txt")).read().strip()
+            with open(os.path.join(dbpath, "version.txt")) as f:
+                return f.read().strip()
         except IOError:
             return ""
 

Modified: CalendarServer/trunk/twistedcaldav/timezonestdservice.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/timezonestdservice.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/timezonestdservice.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -696,7 +696,9 @@
                 # Build TimezoneInfo object
                 tzid = os.path.join(path, item[:-4])
                 try:
-                    md5 = hashlib.md5(open(fullPath).read()).hexdigest()
+                    with open(fullPath) as f:
+                        tzdata = f.read()
+                    md5 = hashlib.md5(tzdata).hexdigest()
                 except IOError:
                     log.error("Unable to read timezone file: %s" % (fullPath,))
                     continue
@@ -711,7 +713,8 @@
 
         # Try links (aliases) file
         try:
-            aliases = open(os.path.join(self.basepath, "links.txt")).read()
+            with open(os.path.join(self.basepath, "links.txt")) as f:
+                aliases = f.read()
         except IOError, e:
             log.error("Unable to read links.txt file: %s" % (str(e),))
             aliases = ""
@@ -922,9 +925,8 @@
             tzpath = os.path.join(self.basepath, tzinfo.tzid) + ".ics"
             if not os.path.exists(os.path.dirname(tzpath)):
                 os.makedirs(os.path.dirname(tzpath))
-            f = open(tzpath, "w")
-            f.write(ical)
-            f.close()
+            with open(tzpath, "w") as f:
+                f.write(ical)
         except IOError, e:
             log.error("Unable to write calendar file for %s: %s" % (tzinfo.tzid, str(e),))
         else:

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -342,7 +342,8 @@
     def createMailTokensDatabase(config, uid, gid):
         # Cause the tokens db to be created on disk so we can set the
         # permissions on it now
-        MailGatewayTokensDatabase(config.DataRoot).lookupByToken("")
+        db = MailGatewayTokensDatabase(config.DataRoot)
+        db.lookupByToken("")
 
         dbPath = os.path.join(config.DataRoot, MailGatewayTokensDatabase.dbFilename)
         if os.path.exists(dbPath):
@@ -352,6 +353,8 @@
         if os.path.exists(journalPath):
             os.chown(journalPath, uid, gid)
 
+        db._db_close()
+
     cuaCache = {}
 
     docRoot = config.DocumentRoot
@@ -1074,6 +1077,7 @@
     yield txn.commit()
 
     # Remove the old file
+    service.close()
     os.remove(service.dbpath)
     journalPath = service.dbpath + "-journal"
     if os.path.exists(journalPath):

Modified: CalendarServer/trunk/txdav/base/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/base/datastore/file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -22,7 +22,7 @@
 
 from zope.interface.declarations import implements
 
-from twisted.python import hashlib
+import hashlib
 
 from twext.python.log import Logger
 from twext.enterprise.ienterprise import AlreadyFinishedError
@@ -249,7 +249,8 @@
             # present. However, our unit tests use static files for their data store and those currently
             # do not include the md5 xattr.
             try:
-                data = self._path.open().read()
+                with self._path.open() as f:
+                    data = f.read()
             except IOError:
                 return None
             md5 = hashlib.md5(data).hexdigest()

Modified: CalendarServer/trunk/txdav/caldav/datastore/index_file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/index_file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/index_file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -95,7 +95,10 @@
         db_filename = self.resource.fp.child(db_basename).path
         super(AbstractCalendarIndex, self).__init__(db_filename, False)
 
+        self.resource._txn.postCommit(self._db_close)
+        self.resource._txn.postAbort(self._db_close)
 
+
     def create(self):
         """
         Create the index and initialize it.
@@ -1103,8 +1106,11 @@
             if name.startswith("."):
                 continue
 
+            child = fp.child(name)
+            if not child.isfile():
+                continue
             try:
-                stream = fp.child(name).open()
+                stream = child.open()
             except (IOError, OSError), e:
                 log.error("Unable to open resource %s: %s" % (name, e))
                 continue
@@ -1215,8 +1221,11 @@
             if name.startswith("."):
                 continue
 
+            child = fp.child(name)
+            if not child.isfile():
+                continue
             try:
-                stream = fp.child(name).open()
+                stream = child.open()
             except (IOError, OSError), e:
                 log.error("Unable to open resource %s: %s" % (name, e))
                 continue

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/mailgateway.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/mailgateway.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/mailgateway.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -235,6 +235,7 @@
             yield txn.imipCreateToken(organizer, attendee, icaluid, token=token)
         yield txn.commit()
 
+        oldDB._db_close()
         os.remove(oldDB.dbpath)
         journalPath = oldDB.dbpath + "-journal"
         if os.path.exists(journalPath):

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_mailgateway.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -49,3 +49,4 @@
         self.assertEquals(records[0].organizer, "urn:uuid:user01")
         self.assertEquals(records[0].attendee, "mailto:attendee at example.com")
         self.assertEquals(records[0].icaluid, "icaluid1")
+        oldDB._db_close()

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -833,6 +833,7 @@
         self.assertEquals(self.sender._scrubHeader("ABC: 123\nXYZ: 456"), "ABC: 123 XYZ: 456")
 
 
+
 def partByType(message, contentType):
     """
     Retrieve a MIME part from an L{email.message.Message} based on a content

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/dkim.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/dkim.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/dkim.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -494,7 +494,9 @@
     def generateSignature(self, headers):
         # Sign the hash
         if self.key_file not in self.keys:
-            self.keys[self.key_file] = RSA.importKey(open(self.key_file).read())
+            with open(self.key_file) as f:
+                key = f.read()
+            self.keys[self.key_file] = RSA.importKey(key)
         return DKIMUtils.sign(headers, self.keys[self.key_file], self.hash_func)
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -57,8 +57,8 @@
         super(TestDKIMBase, self).setUp()
 
         self.private_keyfile = self.mktemp()
-        f = open(self.private_keyfile, "w")
-        f.write("""-----BEGIN RSA PRIVATE KEY-----
+        with open(self.private_keyfile, "w") as f:
+            f.write("""-----BEGIN RSA PRIVATE KEY-----
 MIIEogIBAAKCAQEAw7bJxD1k5VSA5AqdfmJ7vj99oKQ4qYtSeJ5HiK6W40dzC++k
 LweUWLzeUErgXwcJlyOC6rqVVPBfSJq4l7yPdVqpWUo6s2jnUsSWOfhpre22yc4B
 K0QY2Euc3R+gT59eM0mtJPtWaQw5BmQ2GrV6f0OUiKi17jEPasKcxf1qZrWU0+Ik
@@ -86,7 +86,6 @@
 CAXnxZHhrExMGIIa7KV33W5v7Hstl7SnPWKFgCvlBH2QoMTjoUE=
 -----END RSA PRIVATE KEY-----
 """)
-        f.close()
 
         pkey_data = """MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw7bJxD1k5VSA5AqdfmJ7
 vj99oKQ4qYtSeJ5HiK6W40dzC++kLweUWLzeUErgXwcJlyOC6rqVVPBfSJq4l7yP
@@ -97,11 +96,10 @@
 jQIDAQAB
 """
         self.public_keyfile = self.mktemp()
-        f = open(self.public_keyfile, "w")
-        f.write("""-----BEGIN PUBLIC KEY-----
+        with open(self.public_keyfile, "w") as f:
+            f.write("""-----BEGIN PUBLIC KEY-----
 %s-----END PUBLIC KEY-----
 """ % (pkey_data,))
-        f.close()
         self.public_key_data = pkey_data.replace("\n", "")
 
 
@@ -155,7 +153,9 @@
 
             result = request.generateSignature(sign_this)
 
-            key = RSA.importKey(open(self.private_keyfile).read())
+            with open(self.private_keyfile) as f:
+                key = f.read()
+            key = RSA.importKey(key)
             signature = DKIMUtils.sign(sign_this, key, DKIMUtils.hash_func(algorithm))
 
             self.assertEqual(result, signature)
@@ -214,7 +214,9 @@
 ischedule-version:1.0
 ischedule-message-id:%s
 dkim-signature:v=1; d=example.com; s=dkim; t=%s; x=%s; a=%s; q=private-exchange:http/well-known:dns/txt; c=ischedule-relaxed/simple; h=Originator:Recipient:Content-Type:iSchedule-Version:iSchedule-Message-ID; bh=%s; b=""".replace("\n", "\r\n") % (headers.getRawHeaders("Content-Type")[0], request.message_id, request.time, request.expire, algorithm, bodyhash)
-            key = RSA.importKey(open(self.private_keyfile).read())
+            with open(self.private_keyfile) as f:
+                key = f.read()
+            key = RSA.importKey(key)
             signature = DKIMUtils.sign(sign_this, key, DKIMUtils.hash_func(algorithm))
 
             self.assertEqual(result, signature)
@@ -224,7 +226,9 @@
             self.assertEqual(request.headers.getRawHeaders("DKIM-Signature")[0], updated_header)
 
             # Try to verify result using public key
-            pubkey = RSA.importKey(open(self.public_keyfile).read())
+            with open(self.public_keyfile) as f:
+                pubkey = f.read()
+            pubkey = RSA.importKey(pubkey)
             self.assertEqual(DKIMUtils.verify(sign_this, result, pubkey, DKIMUtils.hash_func(algorithm)), None)
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -27,7 +27,8 @@
     def test_readXML(self):
 
         fp = FilePath(self.mktemp())
-        fp.open("w").write("""<?xml version="1.0" encoding="utf-8"?>
+        with fp.open("w") as f:
+            f.write("""<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE servers SYSTEM "servertoserver.dtd">
 <servers>
   <server>

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -41,7 +41,6 @@
 from txweb2.stream import readStream
 
 from twisted.internet.defer import inlineCallbacks, returnValue, succeed
-from twisted.python import hashlib
 from twisted.python.failure import Failure
 
 from twistedcaldav import customxml, ical
@@ -114,6 +113,7 @@
 from urlparse import urlparse, urlunparse
 import collections
 import datetime
+import hashlib
 import itertools
 import urllib
 import uuid

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -24,7 +24,6 @@
 from twisted.internet.defer import Deferred, inlineCallbacks, returnValue, \
     maybeDeferred
 from twisted.internet.protocol import Protocol
-from twisted.python import hashlib
 
 from twext.python.clsprop import classproperty
 from twistedcaldav.ical import Component as VComponent
@@ -54,6 +53,7 @@
 from twistedcaldav.config import config
 from calendarserver.push.util import PushPriority
 
+import hashlib
 import json
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -1789,12 +1789,14 @@
         txn = self._sqlCalendarStore.newTransaction()
         dattachment2 = (yield DropBoxAttachment.load(txn, "1.2", "attach_1_2.txt"))
         self.assertEqual(dattachment2, None)
+        yield txn.commit()
 
         # Managed attachment present
         txn = self._sqlCalendarStore.newTransaction()
         mattachment2 = (yield ManagedAttachment.load(txn, None, None, attachmentID=dattachment._attachmentID))
         self.assertNotEqual(mattachment2, None)
         self.assertTrue(mattachment2.isManaged())
+        yield txn.commit()
 
 
     @inlineCallbacks

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -23,6 +23,7 @@
 # FileStorageTests, or implementation-agnostic methods on CommonTests.
 
 from pycalendar.datetime import DateTime
+from twext.enterprise.ienterprise import AlreadyFinishedError
 from twext.python.filepath import CachingFilePath as FilePath
 from twisted.internet.defer import inlineCallbacks
 from twisted.trial import unittest
@@ -121,6 +122,15 @@
         setUpCalendarStore(self)
 
 
+    @inlineCallbacks
+    def tearDown(self):
+        super(CalendarStoreTest, self).tearDown()
+        try:
+            yield self.txn.commit()
+        except AlreadyFinishedError:
+            pass
+
+
     def test_calendarHomeWithUID_dot(self):
         """
         Filenames starting with "." are reserved by this
@@ -141,6 +151,15 @@
         return setUpHome1(self)
 
 
+    @inlineCallbacks
+    def tearDown(self):
+        super(CalendarHomeTest, self).tearDown()
+        try:
+            yield self.txn.commit()
+        except AlreadyFinishedError:
+            pass
+
+
     def test_init(self):
         """
         L{CalendarHome} has C{_path} and L{_calendarStore} attributes,
@@ -199,6 +218,15 @@
         return setUpCalendar1(self)
 
 
+    @inlineCallbacks
+    def tearDown(self):
+        super(CalendarTest, self).tearDown()
+        try:
+            yield self.txn.commit()
+        except AlreadyFinishedError:
+            pass
+
+
     def test_init(self):
         """
         L{Calendar.__init__} sets private attributes to reflect its constructor
@@ -236,6 +264,7 @@
         index = calendar._index
         self.assertEquals(set((yield index.calendarObjects())),
                           set((yield calendar.calendarObjects())))
+        index._oldIndex._db_close()
 
 
     @inlineCallbacks
@@ -381,11 +410,13 @@
             (yield self.calendar1.calendarObjectWithName("1.ics")).component(),
             VComponent.fromString(event1modified_text)
         )
+        index = self.calendar1._index
         yield self.doThenUndo()
         self.assertEquals(
             (yield self.calendar1.calendarObjectWithName("1.ics")).component(),
             originalComponent
         )
+        index._oldIndex._db_close()
 
 
     @testUnimplemented
@@ -423,6 +454,15 @@
         self.object1 = yield self.calendar1.calendarObjectWithName("1.ics")
 
 
+    @inlineCallbacks
+    def tearDown(self):
+        super(CalendarObjectTest, self).tearDown()
+        try:
+            yield self.txn.commit()
+        except AlreadyFinishedError:
+            pass
+
+
     def test_init(self):
         """
         L{CalendarObject} has instance attributes, C{_path} and C{_calendar},

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_index_file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_index_file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_index_file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -45,7 +45,8 @@
 
 
     def iCalendar(self):
-        text = self.fp.open().read()
+        with self.fp.open() as f:
+            text = f.read()
         try:
             component = Component.fromString(text)
             # Fix any bogus data we can
@@ -66,8 +67,18 @@
     by L{Index}.
     """
 
+    class MinimalTxn(object):
+
+        def postCommit(self, _ignore):
+            pass
+
+        def postAbort(self, _ignore):
+            pass
+
+
     def __init__(self, filePath):
         self.fp = filePath
+        self._txn = MinimalResourceReplacement.MinimalTxn()
 
 
     def isCalendarCollection(self):
@@ -98,6 +109,10 @@
         self.db = Index(MinimalResourceReplacement(self.indexDirPath))
 
 
+    def tearDown(self):
+        self.db._db_close()
+
+
     def test_reserve_uid_ok(self):
         uid = "test-test-test"
         d = self.db.isReservedUID(uid)
@@ -294,9 +309,8 @@
         for description, name, calendar_txt, reCreate, ok in data:
             calendar = Component.fromString(calendar_txt)
             if ok:
-                f = open(os.path.join(self.indexDirPath.path, name), "w")
-                f.write(calendar_txt)
-                del f
+                with open(os.path.join(self.indexDirPath.path, name), "w") as f:
+                    f.write(calendar_txt)
 
                 self.db.addResource(name, calendar, reCreate=reCreate)
                 self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -460,9 +474,8 @@
         for description, name, calendar_txt, trstart, trend in data:
             calendar = Component.fromString(calendar_txt)
 
-            f = open(os.path.join(self.indexDirPath.path, name), "w")
-            f.write(calendar_txt)
-            del f
+            with open(os.path.join(self.indexDirPath.path, name), "w") as f:
+                f.write(calendar_txt)
 
             self.db.addResource(name, calendar)
             self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -646,9 +659,8 @@
         for description, name, calendar_txt, trstart, trend, organizer, instances in data:
             calendar = Component.fromString(calendar_txt)
 
-            f = open(os.path.join(self.indexDirPath.path, name), "w")
-            f.write(calendar_txt)
-            del f
+            with open(os.path.join(self.indexDirPath.path, name), "w") as f:
+                f.write(calendar_txt)
 
             self.db.addResource(name, calendar)
             self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -1053,9 +1065,8 @@
         for description, name, calendar_txt, trstart, trend, organizer, peruserinstances in data:
             calendar = Component.fromString(calendar_txt)
 
-            f = open(os.path.join(self.indexDirPath.path, name), "w")
-            f.write(calendar_txt)
-            del f
+            with open(os.path.join(self.indexDirPath.path, name), "w") as f:
+                f.write(calendar_txt)
 
             self.db.addResource(name, calendar)
             self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -1163,6 +1174,7 @@
 
 
     def tearDown(self):
+        super(MemcacheTests, self).tearDown()
         for _ignore_k, v in self.memcache._timeouts.iteritems():
             if v.active():
                 v.cancel()

Modified: CalendarServer/trunk/txdav/carddav/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/carddav/datastore/file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -33,7 +33,6 @@
 from txweb2.dav.resource import TwistedGETContentMD5
 from txweb2.http_headers import MimeType
 
-from twisted.python import hashlib
 
 from twistedcaldav.vcard import Component as VComponent, InvalidVCardDataError
 from txdav.carddav.datastore.index_file import AddressBookIndex as OldIndex
@@ -53,6 +52,8 @@
 
 from zope.interface import implements
 
+import hashlib
+
 contentTypeKey = PropertyName.fromElement(GETContentType)
 md5key = PropertyName.fromElement(TwistedGETContentMD5)
 

Modified: CalendarServer/trunk/txdav/carddav/datastore/index_file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/index_file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/carddav/datastore/index_file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -265,7 +265,10 @@
         else:
             self.reserver = SQLUIDReserver(self)
 
+        self.resource._txn.postCommit(self._db_close)
+        self.resource._txn.postAbort(self._db_close)
 
+
     def create(self):
         """
         Create the index and initialize it.
@@ -635,8 +638,11 @@
             if name.startswith("."):
                 continue
 
+            child = fp.child(name)
+            if not child.isfile():
+                continue
             try:
-                stream = fp.child(name).open()
+                stream = child.open()
             except (IOError, OSError), e:
                 log.error("Unable to open resource %s: %s" % (name, e))
                 continue

Modified: CalendarServer/trunk/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/sql.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/carddav/datastore/sql.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -38,7 +38,6 @@
 from txweb2.responsecode import FORBIDDEN
 
 from twisted.internet.defer import inlineCallbacks, returnValue, succeed
-from twisted.python import hashlib
 
 from twistedcaldav.config import config
 from twistedcaldav.vcard import Component as VCard, InvalidVCardDataError, Property, \
@@ -69,7 +68,9 @@
 
 from zope.interface.declarations import implements
 
+import hashlib
 
+
 class AddressBookHome(CommonHome):
 
     implements(IAddressBookHome)
@@ -767,7 +768,8 @@
                     missingNameIDs
                 ).on(self._txn, resourceIDs=missingNameIDs)
             )
-            idToNameMap = dict(dict(idToNameMap), **dict(memberIDNameRows))
+            idToNameMap = dict(idToNameMap)
+            idToNameMap.update(dict(memberIDNameRows))
 
         # now do revisions
         if revision:

Modified: CalendarServer/trunk/txdav/carddav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/test/common.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/common.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -24,7 +24,6 @@
 from txweb2.responsecode import FORBIDDEN
 
 from twisted.internet.defer import inlineCallbacks, returnValue, maybeDeferred
-from twisted.python import hashlib
 
 from twistedcaldav.vcard import Component as VComponent
 
@@ -42,7 +41,9 @@
 from txdav.xml.element import WebDAVUnknownElement
 from calendarserver.push.util import PushPriority
 
+import hashlib
 
+
 storePath = FilePath(__file__).parent().child("addressbook_store")
 
 home1Root = storePath.child("ho").child("me").child("home1")

Modified: CalendarServer/trunk/txdav/carddav/datastore/test/test_index_file.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/test/test_index_file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/test_index_file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -33,8 +33,18 @@
     by L{Index}.
     """
 
+    class MinimalTxn(object):
+
+        def postCommit(self, _ignore):
+            pass
+
+        def postAbort(self, _ignore):
+            pass
+
+
     def __init__(self, filePath):
         self.fp = filePath
+        self._txn = MinimalResourceReplacement.MinimalTxn()
 
 
     def isAddressBookCollection(self):
@@ -65,6 +75,10 @@
         self.db = AddressBookIndex(MinimalResourceReplacement(self.indexDirPath))
 
 
+    def tearDown(self):
+        self.db._db_close()
+
+
     def test_reserve_uid_ok(self):
         uid = "test-test-test"
         d = self.db.isReservedUID(uid)
@@ -139,9 +153,8 @@
 
         for description, name, vcard_txt in data:
             calendar = Component.fromString(vcard_txt)
-            f = open(os.path.join(self.site.resource.fp.path, name), "w")
-            f.write(vcard_txt)
-            del f
+            with open(os.path.join(self.site.resource.fp.path, name), "w") as f:
+                f.write(vcard_txt)
 
             self.db.addResource(name, calendar)
             self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -210,6 +223,7 @@
 
 
     def tearDown(self):
+        super(MemcacheTests, self).tearDown()
         for _ignore_k, v in self.memcache._timeouts.iteritems():
             if v.active():
                 v.cancel()

Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/common/datastore/file.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -30,7 +30,6 @@
 
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue
 from twisted.python.util import FancyEqMixin
-from twisted.python import hashlib
 from twisted.python.failure import Failure
 
 from twistedcaldav import customxml
@@ -60,6 +59,7 @@
 from errno import EEXIST, ENOENT
 from zope.interface import implements, directlyProvides
 
+import hashlib
 import json
 import uuid
 from twistedcaldav.sql import AbstractSQLDatabase, db_prefix
@@ -1458,6 +1458,7 @@
     """
     def __init__(self, resource):
         self.resource = resource
+        self._txn = self.resource._txn
         self.fp = self.resource._path
 
 

Modified: CalendarServer/trunk/txdav/who/directory.py
===================================================================
--- CalendarServer/trunk/txdav/who/directory.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/who/directory.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -743,7 +743,7 @@
                 params["EMAIL"] = list(self.emailAddresses)[0].encode("utf-8")
         if "CUTYPE" not in params:
             cuType = self.getCUType()
-            if cuType is not "INDIVIDUAL":
+            if cuType != "INDIVIDUAL":
                 params["CUTYPE"] = cuType
 
         return Property("ATTENDEE", self.canonicalCalendarUserAddress().encode("utf-8"), params=params)

Modified: CalendarServer/trunk/txdav/xml/base.py
===================================================================
--- CalendarServer/trunk/txdav/xml/base.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/xml/base.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -92,7 +92,7 @@
     if not name:
         invalid()
 
-    if name[0] is "{":
+    if name[0] == "{":
         index = name.find("}")
         if (index is -1 or not len(name) > index):
             invalid()

Modified: CalendarServer/trunk/txdav/xml/parser_sax.py
===================================================================
--- CalendarServer/trunk/txdav/xml/parser_sax.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/xml/parser_sax.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -84,7 +84,7 @@
 
         attributes_dict = {}
 
-        if attributes.getLength() is not 0:
+        if attributes.getLength() != 0:
             for attr_name in attributes.getQNames():
                 attributes_dict[attr_name.encode("utf-8")] = attributes.getValueByQName(attr_name)
 

Modified: CalendarServer/trunk/txdav/xml/rfc2518.py
===================================================================
--- CalendarServer/trunk/txdav/xml/rfc2518.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txdav/xml/rfc2518.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -313,8 +313,8 @@
                 )
             )
 
-        if status_count is 0:
-            if propstat_count is 0:
+        if status_count == 0:
+            if propstat_count == 0:
                 raise ValueError(
                     "{0} element must have one of {1} or {2}".format(
                         cls.sname(), Status.sname(), PropertyStatus.sname()

Modified: CalendarServer/trunk/txweb2/auth/digest.py
===================================================================
--- CalendarServer/trunk/txweb2/auth/digest.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/auth/digest.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -31,7 +31,8 @@
 
 from zope.interface import implements
 
-from twisted.python.hashlib import md5, sha1
+from hashlib import md5, sha1
+
 from twisted.cred import credentials
 
 # FIXME: Technically speaking - although you can't tell from looking at them -

Modified: CalendarServer/trunk/txweb2/dav/fileop.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/fileop.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/dav/fileop.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -468,6 +468,7 @@
         ))
 
     # Remove stat info from filepath since we modified the backing file
+    resource_file.close()
     filepath.changed()
     yield success_code
 

Modified: CalendarServer/trunk/txweb2/dav/method/propfind.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/method/propfind.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/dav/method/propfind.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -145,7 +145,7 @@
 
     for resource, uri in resources:
 
-        if search_properties is "names":
+        if search_properties == "names":
             try:
                 resource_properties = waitForDeferred(resource.listProperties(request))
                 yield resource_properties
@@ -163,7 +163,7 @@
                 responsecode.NOT_FOUND : [],
             }
 
-            if search_properties is "all":
+            if search_properties == "all":
                 properties_to_enumerate = waitForDeferred(resource.listAllprop(request))
                 yield properties_to_enumerate
                 properties_to_enumerate = properties_to_enumerate.getResult()

Modified: CalendarServer/trunk/txweb2/dav/test/test_xattrprops.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/test/test_xattrprops.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/dav/test/test_xattrprops.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -238,7 +238,7 @@
         error = self.assertRaises(HTTPError, self.propertyStore.get, property)
         self.assertEquals(error.response.code, INTERNAL_SERVER_ERROR)
         self.assertEquals(
-            len(self.flushLoggedErrors(UnpicklingError)), 1)
+            len(self.flushLoggedErrors(UnpicklingError, IndexError)), 1)
 
 
     def test_set(self):

Modified: CalendarServer/trunk/txweb2/dav/util.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/util.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/dav/util.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -168,7 +168,7 @@
     (scheme, host, path, _ignore_query, _ignore_fragment) = urlsplit(normalizeURL(url))
 
     index = path.rfind("/")
-    if index is 0:
+    if index == 0:
         if path == "/":
             return None
         else:

Modified: CalendarServer/trunk/txweb2/dav/xattrprops.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/xattrprops.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/dav/xattrprops.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -188,6 +188,12 @@
                 err(None, msg)
                 raise HTTPError(
                     StatusResponse(responsecode.INTERNAL_SERVER_ERROR, msg))
+            except Exception:
+                format = "Invalid property value stored on server: %s %s"
+                msg = format % (encodeXMLName(*qname), data)
+                err(None, msg)
+                raise HTTPError(
+                    StatusResponse(responsecode.INTERNAL_SERVER_ERROR, msg))
             else:
                 legacy = True
 

Modified: CalendarServer/trunk/txweb2/static.py
===================================================================
--- CalendarServer/trunk/txweb2/static.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/static.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -551,6 +551,7 @@
             fileobject = os.fdopen(os.open(outname, flags, self.permissions), 'wb', 0)
 
             stream.readIntoFile(filestream, fileobject)
+            fileobject.close()
 
         return outname
 

Modified: CalendarServer/trunk/txweb2/test/test_httpauth.py
===================================================================
--- CalendarServer/trunk/txweb2/test/test_httpauth.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/test/test_httpauth.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -1,7 +1,6 @@
 # Copyright (c) 2006-2009 Twisted Matrix Laboratories.
 # See LICENSE for details.
 
-from twisted.python.hashlib import md5
 from twisted.internet import address
 from twisted.trial import unittest
 from twisted.cred import error
@@ -13,6 +12,7 @@
 from txweb2.test import test_server
 
 import base64
+from hashlib import md5
 
 _trivial_GET = SimpleRequest(None, 'GET', '/')
 

Modified: CalendarServer/trunk/txweb2/test/test_stream.py
===================================================================
--- CalendarServer/trunk/txweb2/test/test_stream.py	2015-11-04 17:17:02 UTC (rev 15284)
+++ CalendarServer/trunk/txweb2/test/test_stream.py	2015-11-04 19:06:32 UTC (rev 15285)
@@ -5,6 +5,7 @@
 Tests for the stream implementations in L{txweb2}.
 """
 
+from hashlib import md5
 import os
 import sys
 import tempfile
@@ -13,7 +14,6 @@
 
 from twisted.python.util import sibpath
 sibpath # sibpath is *not* unused - the doctests use it.
-from twisted.python.hashlib import md5
 from twisted.internet import reactor, defer, interfaces
 from twisted.trial import unittest
 from txweb2 import stream
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151104/1bd85789/attachment-0001.html>


More information about the calendarserver-changes mailing list