Commit 4b4dc776 authored by ericw's avatar ericw
Browse files

Special handling at CERN site

parent 6b41be2a
......@@ -10,7 +10,7 @@ Tests the local FroNtier squid
# 3) file $CMS_PATH/SITECONF/local/JobConfig/site-local-config.xml
# contains the location of the local FroNtier squid server
#
__revision__ = "$Id: test_squid.py,v 1.1 2007/02/09 21:27:01 ericw Exp $"
__revision__ = "$Id: test_squid.py,v 1.2 2007/02/12 17:31:13 ericw Exp $"
import os
import sys
import urllib2
......@@ -44,29 +44,47 @@ if not os.environ.has_key("CMS_PATH"):
# Check that file $CMS_PATH/SITECONF/local/JobConfig/site-local-config.xml
# exists
#
slc = os.environ["CMS_PATH"] + \
"/SITECONF/local/JobConfig/site-local-config.xml"
if not os.path.exists(slc):
print "test_squid.py: Error. file " + slc + " does not exist"
slcfil = os.environ["CMS_PATH"] + \
"/SITECONF/local/JobConfig/site-local-config.xml"
if not os.path.exists(slcfil):
print "test_squid.py: Error. file " + slcfil + " does not exist"
#
# Parse site-local-config.xml for local FroNtier squid server
# Read and parse site-local-config.xml into a dom
# See http://docs.python.org/lib/module-xml.dom.minidom.html
#
slcdom = parse(slc)
plist = slcdom.getElementsByTagName("proxy")
slcdom = parse(slcfil)
#
# Work out site name from site-local-config.xml
#
silist = slcdom.getElementsByTagName("site")
if len(silist) == 0:
site = "UNKNOWN"
else:
stag = silist[0]
site = stag.getAttribute("name")
print "site " + site
#
# Work out local FroNtier squid server from site-local-config.xml
# Note that http_proxy is not set when running on CERN site
#
if site != "CERN":
#
# Check for at least one proxy tag
#
if len(plist) == 0:
print "test_squid.py: Error. no proxy tag in file " + slc
sys.exit(same_error)
prlist = slcdom.getElementsByTagName("proxy")
if len(prlist) == 0:
print "test_squid.py: Error. no proxy tag in file " + slcfil
sys.exit(same_error)
#
# Set proxy
# Work out address of squid
#
ptag = plist[0]
squid = ptag.getAttribute("url")
print "squid " + squid
os.environ["http_proxy"] = squid
prtag = prlist[0]
squid = prtag.getAttribute("url")
#
# Set proxy server
#
print "squid " + squid
os.environ["http_proxy"] = squid
#
# Following code from Sinisa Veseli
#
......@@ -116,14 +134,19 @@ if statsFlag:
pass
else:
print "\nQuery started: ", time.strftime("%m/%d/%y %H:%M:%S", queryStart)
t1 = time.time()
#
try:
result = urllib2.urlopen(request).read()
except urllib2.URLError:
print "test_squid.py: Error. squid " + squid + " is down or unreachable"
sys.exit(same_error)
if site != "CERN":
print "test_squid.py: Error. squid " + squid + \
" is down or unreachable"
sys.exit(same_error)
else:
print "test_squid.py: Error. FroNtier server " + frontierUrl + \
" is down or unreachable"
sys.exit(same_error)
except:
print "test_squid.py: Error."
sys.exit(same_error)
......@@ -148,7 +171,6 @@ if decodeFlag:
# and will simply replace those by space.
for data in dataList:
if data.firstChild is not None:
row = base64.decodestring(data.firstChild.data)
if retrieveZiplevel != "":
row = zlib.decompress(row)
......@@ -157,7 +179,6 @@ if decodeFlag:
'\x0b', '\x0c', '\x0d', '\x1b', '\x17' ]
for c in control:
row = row.replace(c, ' ')
print "\nFields: "
endFirstRow = row.find('\x07')
firstRow = row[:endFirstRow]
......@@ -165,7 +186,6 @@ if decodeFlag:
if curses.ascii.isctrl(c):
firstRow = firstRow.replace(c, '\n')
print firstRow
print "\nRecords:"
pos = endFirstRow + 1
while True:
......@@ -177,8 +197,8 @@ if decodeFlag:
pos = pos + endRow + 1
fixedRow = fixedRow.replace('\n', '')
print fixedRow
#
# Exit with success exit code
#
print "OK"
sys.exit(same_ok)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment