aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/scripts/template_verifier.py
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/scripts/template_verifier.py
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rwxr-xr-xlinden/scripts/template_verifier.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/linden/scripts/template_verifier.py b/linden/scripts/template_verifier.py
index 73bd329..f1f3953 100755
--- a/linden/scripts/template_verifier.py
+++ b/linden/scripts/template_verifier.py
@@ -145,9 +145,20 @@ def cache_master(master_url):
145 print "Cause: %s" % e 145 print "Cause: %s" % e
146 return master_cache_url 146 return master_cache_url
147 try: 147 try:
148 mc = open(master_cache, 'wb') 148 tmpname = '%s.%d' % (master_cache, os.getpid())
149 mc = open(tmpname, 'wb')
149 mc.write(new_master_contents) 150 mc.write(new_master_contents)
150 mc.close() 151 mc.close()
152 try:
153 os.rename(tmpname, master_cache)
154 except OSError:
155 # We can't rename atomically on top of an existing file on
156 # Windows. Unlinking the existing file will fail if the
157 # file is being held open by a process, but there's only
158 # so much working around a lame I/O API one can take in
159 # a single day.
160 os.unlink(master_cache)
161 os.rename(tmpname, master_cache)
151 except IOError, e: 162 except IOError, e:
152 print "WARNING: Unable to write master message template to %s, proceeding without cache." % master_cache 163 print "WARNING: Unable to write master message template to %s, proceeding without cache." % master_cache
153 print "Cause: %s" % e 164 print "Cause: %s" % e
@@ -160,12 +171,22 @@ def local_template_filename():
160 d = os.path.dirname(os.path.realpath(__file__)) 171 d = os.path.dirname(os.path.realpath(__file__))
161 return os.path.join(d, 'messages', MESSAGE_TEMPLATE) 172 return os.path.join(d, 'messages', MESSAGE_TEMPLATE)
162 173
174def getuser():
175 try:
176 # Unix-only.
177 import getpass
178 return getpass.getuser()
179 except ImportError:
180 import win32api
181 return win32api.GetUserName()
182
163def local_master_cache_filename(): 183def local_master_cache_filename():
164 """Returns the location of the master template cache (which is in the system tempdir) 184 """Returns the location of the master template cache (which is in the system tempdir)
165 <temp_dir>/master_message_template_cache.msg""" 185 <temp_dir>/master_message_template_cache.msg"""
166 import tempfile 186 import tempfile
167 d = tempfile.gettempdir() 187 d = tempfile.gettempdir()
168 return os.path.join(d, 'master_message_template_cache.msg') 188 user = getuser()
189 return os.path.join(d, 'master_message_template_cache.%s.msg' % user)
169 190
170 191
171def run(sysargs): 192def run(sysargs):