You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2008/05/06 20:31:11 UTC
svn commit: r653875 - in /incubator/qpid/trunk/qpid/python: qpid/spec010.py
tests/spec010.py
Author: rhs
Date: Tue May 6 11:31:11 2008
New Revision: 653875
URL: http://svn.apache.org/viewvc?rev=653875&view=rev
Log:
QPID-1033: made loading of the spec file not fail if the results cannot be cached, e.g. due to an unwritable directory
Modified:
incubator/qpid/trunk/qpid/python/qpid/spec010.py
incubator/qpid/trunk/qpid/python/tests/spec010.py
Modified: incubator/qpid/trunk/qpid/python/qpid/spec010.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/spec010.py?rev=653875&r1=653874&r2=653875&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/spec010.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/spec010.py Tue May 6 11:31:11 2008
@@ -621,6 +621,7 @@
def load(xml):
fname = xml + ".pcl"
+
if os.path.exists(fname) and mtime(fname) > mtime(__file__):
file = open(fname, "r")
s = cPickle.load(file)
@@ -630,7 +631,14 @@
s = doc["amqp"].dispatch(Loader())
s.register()
s.resolve()
- file = open(fname, "w")
- cPickle.dump(s, file)
- file.close()
+
+ try:
+ file = open(fname, "w")
+ except IOError:
+ file = None
+
+ if file:
+ cPickle.dump(s, file)
+ file.close()
+
return s
Modified: incubator/qpid/trunk/qpid/python/tests/spec010.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests/spec010.py?rev=653875&r1=653874&r2=653875&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests/spec010.py (original)
+++ incubator/qpid/trunk/qpid/python/tests/spec010.py Tue May 6 11:31:11 2008
@@ -17,6 +17,7 @@
# under the License.
#
+import os, tempfile, shutil, stat
from unittest import TestCase
from qpid.spec010 import load
from qpid.codec010 import Codec, StringCodec
@@ -70,3 +71,14 @@
xid.encode(sc, st)
assert sc.encoded == '\x00\x00\x00\x10\x06\x04\x07\x00\x00\x00\x00\x00\x03gid\x03bid'
assert xid.decode(sc).__dict__ == st.__dict__
+
+ def testLoadReadOnly(self):
+ spec = "amqp.0-10-qpid-errata.xml"
+ f = testrunner.get_spec_file(spec)
+ dest = tempfile.mkdtemp()
+ shutil.copy(f, dest)
+ shutil.copy(os.path.join(os.path.dirname(f), "amqp.0-10.dtd"), dest)
+ os.chmod(dest, stat.S_IRUSR | stat.S_IXUSR)
+ fname = os.path.join(dest, spec)
+ load(fname)
+ assert not os.path.exists("%s.pcl" % fname)