[CalendarServer-changes] [14907] CalendarServer/branches/users/cdaboo/cfod
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 23 09:22:03 PDT 2015
Revision: 14907
http://trac.calendarserver.org//changeset/14907
Author: cdaboo at apple.com
Date: 2015-06-23 09:22:03 -0700 (Tue, 23 Jun 2015)
Log Message:
-----------
PyPy fixes: mostly ensuring files are closed, or use "=="/"!=" instead of "is"/"is not".
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/cfod/calendarserver/push/util.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/caldav.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/profiling.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/calverify_diff.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/dkimtool.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/managetimezones.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/migrate_verify.py
CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/obliterate.py
CalendarServer/branches/users/cdaboo/cfod/contrib/od/test/test_live.py
CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/ical.py
CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/population.py
CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/profiles.py
CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/test_ical.py
CalendarServer/branches/users/cdaboo/cfod/contrib/performance/sqlusage/requests/httpTests.py
CalendarServer/branches/users/cdaboo/cfod/contrib/tools/harpoon.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/directory/test/test_proxyprincipaldb.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/localization.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/stdconfig.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_caldavxml.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_calendarquery.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_config.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_xmlutil.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezones.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezonestdservice.py
CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/upgrade.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/dkim.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_attachments.py
CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_index_file.py
CalendarServer/branches/users/cdaboo/cfod/txdav/carddav/datastore/test/test_index_file.py
CalendarServer/branches/users/cdaboo/cfod/txdav/who/directory.py
CalendarServer/branches/users/cdaboo/cfod/txdav/xml/base.py
CalendarServer/branches/users/cdaboo/cfod/txdav/xml/parser_sax.py
CalendarServer/branches/users/cdaboo/cfod/txdav/xml/rfc2518.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/fileop.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/method/propfind.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/test/test_xattrprops.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/util.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/xattrprops.py
CalendarServer/branches/users/cdaboo/cfod/txweb2/static.py
Modified: CalendarServer/branches/users/cdaboo/cfod/calendarserver/push/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/push/util.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/push/util.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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()
x509 = crypto.load_certificate(crypto.FILETYPE_PEM, certData)
subject = x509.get_subject()
components = subject.get_components()
Modified: CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/caldav.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/caldav.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -759,7 +759,7 @@
else:
logID = ""
- if config.ProcessType is not "Utility":
+ if config.ProcessType != "Utility":
execName = ""
setproctitle(
@@ -1242,7 +1242,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/branches/users/cdaboo/cfod/calendarserver/tap/profiling.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/profiling.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tap/profiling.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/calendarserver/tools/calverify_diff.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/calverify_diff.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/calverify_diff.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/calendarserver/tools/dkimtool.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/dkimtool.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/dkimtool.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/calendarserver/tools/managetimezones.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/managetimezones.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/managetimezones.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/calendarserver/tools/migrate_verify.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/migrate_verify.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/migrate_verify.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -192,6 +192,8 @@
invalidGUIDs.add(segments[3])
self.badPaths.append(line)
+ datafile.close()
+
# Remove any invalid GUIDs that actuall were valid
invalidGUIDs = [pguid for pguid in invalidGUIDs if pguid not in self.pathsByGUID]
Modified: CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/obliterate.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/obliterate.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/calendarserver/tools/obliterate.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/contrib/od/test/test_live.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/od/test/test_live.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/od/test/test_live.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -73,10 +73,6 @@
def setUp(self):
self.service = DirectoryService()
- def tearDown(self):
- self.service._deletePool()
-
-
def verifyResults(self, records, expected, unexpected):
shortNames = []
for record in records:
Modified: CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/ical.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/ical.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -1329,7 +1329,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):
@@ -1346,7 +1347,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/branches/users/cdaboo/cfod/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/population.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/population.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/contrib/performance/loadtest/profiles.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/profiles.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/profiles.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/contrib/performance/loadtest/test_ical.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/test_ical.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/performance/loadtest/test_ical.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/contrib/performance/sqlusage/requests/httpTests.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/performance/sqlusage/requests/httpTests.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/performance/sqlusage/requests/httpTests.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/contrib/tools/harpoon.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/contrib/tools/harpoon.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/contrib/tools/harpoon.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/twistedcaldav/directory/test/test_proxyprincipaldb.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/directory/test/test_proxyprincipaldb.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/directory/test/test_proxyprincipaldb.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/twistedcaldav/localization.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/localization.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/localization.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -443,8 +443,10 @@
# can't create directory to hold .po file
return
- # Parse the binary plist .strings file:
- data = CFDataRef.fromString(open(src).read())
+ # Parse the binary plist .strings file
+ with open(src) as f:
+ data = f.read()
+ data = CFDataRef.fromString(data)
try:
parsed = CFPropertyListRef.createFromData(data)
strings = parsed.toDict()
Modified: CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/stdconfig.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/stdconfig.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -1185,7 +1185,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/branches/users/cdaboo/cfod/twistedcaldav/test/test_caldavxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_caldavxml.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_caldavxml.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -76,7 +76,7 @@
EXDATE:20080602T120000Z
EXDATE:20080603T120000Z
ORGANIZER;CN=User 01:mailto:user1 at example.com
-RRULE:FREQ=DAILY;COUNT=400
+RRULE:FREQ=DAILY
SUMMARY:Test
END:VEVENT
END:VCALENDAR
@@ -103,7 +103,7 @@
["exdate", {}, "date-time", "2008-06-02T12:00:00Z"],
["exdate", {}, "date-time", "2008-06-03T12:00:00Z"],
["organizer", {"cn": "User 01"}, "cal-address", "mailto:user1 at example.com"],
- ["rrule", {}, "recur", {"count": 400, "freq": "DAILY"}],
+ ["rrule", {}, "recur", {"freq": "DAILY"}],
["summary", {}, "text", "Test"]
],
[
Modified: CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_calendarquery.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_calendarquery.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_calendarquery.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/twistedcaldav/test/test_config.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_config.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_config.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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):
@@ -551,10 +552,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)
@@ -616,10 +619,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)
@@ -681,10 +686,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/branches/users/cdaboo/cfod/twistedcaldav/test/test_xmlutil.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_xmlutil.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/test/test_xmlutil.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezones.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezones.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/twistedcaldav/timezonestdservice.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezonestdservice.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/timezonestdservice.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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 = ""
Modified: CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/upgrade.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/twistedcaldav/upgrade.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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
Modified: CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -585,6 +585,7 @@
txn, inputOriginator, inputRecipient,
Component.fromString(inputCalendar.replace("\n", "\r\n")),
onlyAfter=DateTime(2010, 1, 1, 0, 0, 0))
+ yield txn.commit()
# Verify we didn't create a new token...
txn = self.store.newTransaction()
Modified: CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/dkim.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/dkim.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/dkim.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_dkim.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -155,7 +155,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 +216,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 +228,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/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/scheduling/ischedule/test/test_remoteservers.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_attachments.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_attachments.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -1771,12 +1771,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/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_index_file.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_index_file.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/caldav/datastore/test/test_index_file.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -98,6 +98,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)
@@ -296,7 +300,7 @@
if ok:
f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
- del f
+ f.close()
self.db.addResource(name, calendar, reCreate=reCreate)
self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -462,7 +466,7 @@
f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
- del f
+ f.close()
self.db.addResource(name, calendar)
self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -648,7 +652,7 @@
f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
- del f
+ f.close()
self.db.addResource(name, calendar)
self.assertTrue(self.db.resourceExists(name), msg=description)
@@ -1055,7 +1059,7 @@
f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
- del f
+ f.close()
self.db.addResource(name, calendar)
self.assertTrue(self.db.resourceExists(name), msg=description)
Modified: CalendarServer/branches/users/cdaboo/cfod/txdav/carddav/datastore/test/test_index_file.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/carddav/datastore/test/test_index_file.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/carddav/datastore/test/test_index_file.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -65,6 +65,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)
@@ -141,7 +145,7 @@
calendar = Component.fromString(vcard_txt)
f = open(os.path.join(self.site.resource.fp.path, name), "w")
f.write(vcard_txt)
- del f
+ f.close()
self.db.addResource(name, calendar)
self.assertTrue(self.db.resourceExists(name), msg=description)
Modified: CalendarServer/branches/users/cdaboo/cfod/txdav/who/directory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/who/directory.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/who/directory.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -713,7 +713,7 @@
params = params.copy() if params else params
if "PARTSTAT" not in params:
params["PARTSTAT"] = "NEEDS-ACTION"
- if "CN"not in params:
+ if "CN" not in params:
if self.displayName:
params["CN"] = self.displayName.encode("utf-8")
if "EMAIL" not in params:
@@ -721,7 +721,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/branches/users/cdaboo/cfod/txdav/xml/base.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/xml/base.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/xml/base.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txdav/xml/parser_sax.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/xml/parser_sax.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/xml/parser_sax.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txdav/xml/rfc2518.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txdav/xml/rfc2518.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txdav/xml/rfc2518.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/dav/fileop.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/fileop.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/fileop.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/dav/method/propfind.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/method/propfind.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/method/propfind.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/dav/test/test_xattrprops.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/test/test_xattrprops.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/test/test_xattrprops.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/dav/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/util.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/util.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/dav/xattrprops.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/xattrprops.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/dav/xattrprops.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -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/branches/users/cdaboo/cfod/txweb2/static.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cfod/txweb2/static.py 2015-06-23 01:09:10 UTC (rev 14906)
+++ CalendarServer/branches/users/cdaboo/cfod/txweb2/static.py 2015-06-23 16:22:03 UTC (rev 14907)
@@ -551,6 +551,7 @@
fileobject = os.fdopen(os.open(outname, flags, self.permissions), 'wb', 0)
stream.readIntoFile(filestream, fileobject)
+ fileobject.close()
return outname
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150623/efbef97d/attachment-0001.html>
More information about the calendarserver-changes
mailing list