summaryrefslogtreecommitdiff
path: root/scripts/template_verifier.py
diff options
context:
space:
mode:
authorRyan Williams <rdw@lindenlab.com>2007-07-19 01:09:12 +0000
committerRyan Williams <rdw@lindenlab.com>2007-07-19 01:09:12 +0000
commit168794a0f348bb4d1e29a091bcbd39a220918054 (patch)
tree128105d5df1f3dd39699faa9639cfc2d958ce946 /scripts/template_verifier.py
parentfbb133a46a98fce4220b14f92826d1d42b65d9ba (diff)
Replaced usage of urlopen.read(), which isn't guaranteed to return all of the downloaded bytes, with urlopen.readlines(), which (I believe) does have that guarantee. This should fix the rash of mysteriously-failing prebuilds. In the process, added some better error messaging about whether the local template has the parse error, or the master on the network. Also some reorganization. Reviewed by Tess and Leyla.
Diffstat (limited to 'scripts/template_verifier.py')
-rwxr-xr-xscripts/template_verifier.py48
1 files changed, 30 insertions, 18 deletions
diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py
index 980ceb8df8..67728d73d8 100755
--- a/scripts/template_verifier.py
+++ b/scripts/template_verifier.py
@@ -23,35 +23,38 @@ import sys
import urllib
from indra.ipc import compatibility
+from indra.ipc import tokenstream
from indra.ipc import llmessage
-def die(msg):
- print >>sys.stderr, msg
- sys.exit(1)
-
-MESSAGE_TEMPLATE = 'message_template.msg'
-
-PRODUCTION_ACCEPTABLE = (compatibility.Same, compatibility.Newer)
-DEVELOPMENT_ACCEPTABLE = (
- compatibility.Same, compatibility.Newer,
- compatibility.Older, compatibility.Mixed)
-
def getstatusall(command):
""" Like commands.getstatusoutput, but returns stdout and
stderr separately(to get around "killed by signal 15" getting
included as part of the file). Also, works on Windows."""
(input, out, err) = os.popen3(command, 't')
- input.close() # send no input to the command
+ status = input.close() # send no input to the command
output = out.read()
error = err.read()
- out.close()
- status = err.close() # the status comes from the *last* pipe you close
+ status = out.close()
+ status = err.close() # the status comes from the *last* pipe that is closed
return status, output, error
def getstatusoutput(command):
status, output, error = getstatusall(command)
return status, output
+
+def die(msg):
+ print >>sys.stderr, msg
+ sys.exit(1)
+
+MESSAGE_TEMPLATE = 'message_template.msg'
+
+PRODUCTION_ACCEPTABLE = (compatibility.Same, compatibility.Newer)
+DEVELOPMENT_ACCEPTABLE = (
+ compatibility.Same, compatibility.Newer,
+ compatibility.Older, compatibility.Mixed)
+
+
def compare(base, current, mode):
"""Compare the current template against the base template using the given
'mode' strictness:
@@ -65,9 +68,18 @@ def compare(base, current, mode):
Returns a tuple of (bool, Compatibility)
Return True if they are compatible in this mode, False if not.
"""
- base = llmessage.parseTemplateString(base)
- current = llmessage.parseTemplateString(current)
-
+ try:
+ base = llmessage.parseTemplateString(base)
+ except tokenstream.ParseError, e:
+ print "Error parsing master message template -- this might be a network problem, try again"
+ raise e
+
+ try:
+ current = llmessage.parseTemplateString(current)
+ except tokenstream.ParseError, e:
+ print "Error parsing local message template"
+ raise e
+
compat = current.compatibleWithBase(base)
if mode == 'production':
acceptable = PRODUCTION_ACCEPTABLE
@@ -126,7 +138,7 @@ http://wiki.secondlife.com/wiki/Template_verifier.py
# fetch the master from the url (default or supplied)
if master is None:
- master = urllib.urlopen(options.master_url).read()
+ master = ''.join(urllib.urlopen(options.master_url).readlines())
# fetch the template for this build
if current is None: