##// END OF EJS Templates
Make makelock and readlock work on filesystems without symlink support....
Thomas Arendsen Hein -
r704:5ca319a6 default
parent child Browse files
Show More
@@ -37,7 +37,7 b' class lock:'
37 37 try:
38 38 util.makelock(str(pid), self.f)
39 39 self.held = 1
40 except:
40 except (OSError, IOError):
41 41 raise LockHeld(util.readlock(self.f))
42 42
43 43 def release(self):
@@ -5,7 +5,7 b''
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import os
8 import os, errno
9 9
10 10 def unique(g):
11 11 seen = {}
@@ -61,6 +61,14 b' def copytree(src, dst, copyfile):'
61 61 else:
62 62 raise IOError("Not a regular file: %r" % srcname)
63 63
64 def _makelock_file(info, pathname):
65 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
66 os.write(ld, info)
67 os.close(ld)
68
69 def _readlock_file(pathname):
70 return file(pathname).read()
71
64 72 # Platfor specific varients
65 73 if os.name == 'nt':
66 74 nulldev = 'NUL:'
@@ -74,13 +82,8 b" if os.name == 'nt':"
74 82 def pconvert(path):
75 83 return path.replace("\\", "/")
76 84
77 def makelock(info, pathname):
78 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
79 os.write(ld, info)
80 os.close(ld)
81
82 def readlock(pathname):
83 return file(pathname).read()
85 makelock = _makelock_file
86 readlock = _readlock_file
84 87
85 88 else:
86 89 nulldev = '/dev/null'
@@ -105,7 +108,19 b' else:'
105 108 return path
106 109
107 110 def makelock(info, pathname):
108 os.symlink(info, pathname)
111 try:
112 os.symlink(info, pathname)
113 except OSError, why:
114 if why.errno == errno.EEXIST:
115 raise
116 else:
117 _makelock_file(info, pathname)
109 118
110 119 def readlock(pathname):
111 return os.readlink(pathname)
120 try:
121 return os.readlink(pathname)
122 except OSError, why:
123 if why.errno == errno.EINVAL:
124 return _readlock_file(pathname)
125 else:
126 raise
General Comments 0
You need to be logged in to leave comments. Login now