Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
etf
cmssam
Commits
4b4dc776
Commit
4b4dc776
authored
Feb 12, 2007
by
ericw
Browse files
Special handling at CERN site
parent
6b41be2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
SiteTests/FroNtier/tests/test_squid.py
View file @
4b4dc776
...
...
@@ -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"
slc
fil
=
os
.
environ
[
"CMS_PATH"
]
+
\
"/SITECONF/local/JobConfig/site-local-config.xml"
if
not
os
.
path
.
exists
(
slc
fil
):
print
"test_squid.py: Error. file "
+
slc
fil
+
" does not exist"
#
#
P
arse site-local-config.xml
for local FroNtier squid server
#
Read and p
arse 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
"
\n
Query 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
"
\n
Fields: "
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
"
\n
Records:"
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment