summaryrefslogtreecommitdiff
path: root/scripts/template_verifier.py
diff options
context:
space:
mode:
authorChristian Goetze <cg@lindenlab.com>2008-02-11 23:32:18 +0000
committerChristian Goetze <cg@lindenlab.com>2008-02-11 23:32:18 +0000
commit4b39451ff14a735208b9e26207a13f2a7a2a9b72 (patch)
treefe47b343d4c4e3b0f1596843f29c8f442e17e54b /scripts/template_verifier.py
parent446b7ecea2e1635bd66087894f23e3a45eb7b607 (diff)
$ svn merge -c79668 svn+ssh://svn.lindenlab.com/svn/linden/branches/cmake-3
merge in the fix for template_verifier which avoids multiple concurrent builds from stomping on each other.
Diffstat (limited to 'scripts/template_verifier.py')
-rwxr-xr-xscripts/template_verifier.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py
index ac814aedc0..a7dbda9e3b 100755
--- a/scripts/template_verifier.py
+++ b/scripts/template_verifier.py
@@ -145,9 +145,20 @@ def cache_master(master_url):
print "Cause: %s" % e
return master_cache_url
try:
- mc = open(master_cache, 'wb')
+ tmpname = '%s.%d' % (master_cache, os.getpid())
+ mc = open(tmpname, 'wb')
mc.write(new_master_contents)
mc.close()
+ try:
+ os.rename(tmpname, master_cache)
+ except OSError:
+ # We can't rename atomically on top of an existing file on
+ # Windows. Unlinking the existing file will fail if the
+ # file is being held open by a process, but there's only
+ # so much working around a lame I/O API one can take in
+ # a single day.
+ os.unlink(master_cache)
+ os.rename(tmpname, master_cache)
except IOError, e:
print "WARNING: Unable to write master message template to %s, proceeding without cache." % master_cache
print "Cause: %s" % e
@@ -160,12 +171,22 @@ def local_template_filename():
d = os.path.dirname(os.path.realpath(__file__))
return os.path.join(d, 'messages', MESSAGE_TEMPLATE)
+def getuser():
+ try:
+ # Unix-only.
+ import getpass
+ return getpass.getuser()
+ except ImportError:
+ import win32api
+ return win32api.GetUserName()
+
def local_master_cache_filename():
"""Returns the location of the master template cache (which is in the system tempdir)
<temp_dir>/master_message_template_cache.msg"""
import tempfile
d = tempfile.gettempdir()
- return os.path.join(d, 'master_message_template_cache.msg')
+ user = getuser()
+ return os.path.join(d, 'master_message_template_cache.%s.msg' % user)
def run(sysargs):