Commit c5772086 authored by Duncan Brown's avatar Duncan Brown
Browse files

deleted obsolete files and updated for 1.19 release

parent e8a668a7
#!/usr/bin/python
#
# Copyright (C) 2006 Kipp C. Cannon
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# =============================================================================
#
# Preamble
#
# =============================================================================
#
"""
This utility checks that the output of LSCdataFind spans a given segment,
and optionally that the files are accessible.
"""
from optparse import OptionParser
import os
import sys
from glue.lal import CacheEntry
from glue.lal import LIGOTimeGPS
from glue import segments
from glue import segmentsUtils
__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>"
__date__ = "$Date$"[7:-2]
__version__ = "$Revision$"[11:-2]
#
# =============================================================================
#
# Error Messages
#
# =============================================================================
#
def write_error_lines(lines):
for line in lines:
print >>sys.stderr, "LSCdataFindcheck: error:", line
#
# =============================================================================
#
# Command Line
#
# =============================================================================
#
def parse_command_line():
parser = OptionParser(version = "%prog CVS $Id$")
parser.add_option("--segwizard-segments", metavar = "filename", help = "Read segments to check from the named segwizard-format text file.")
parser.add_option("--gps-start-time", metavar = "seconds", help = "Check a single segment starting at this time (must also set --gps-end-time).")
parser.add_option("--gps-end-time", metavar = "seconds", help = "Check a single segment ending at this time (must also set --gps-start-time).")
parser.add_option("--gps-segment-list", metavar = "start:end[,start:end]...", help = "Check this list of segments.")
parser.add_option("--dagman-return", metavar = "value", default = 0, help = "Set $RETURN value from dagman.")
parser.add_option("--stat", action = "store_true", default = False, help = "Test that files exist and are accessible.")
parser.add_option("-v", "--verbose", action = "store_true", default = False, help = "Be verbose.")
options, filenames = parser.parse_args()
if options.dagman_return:
options.dagman_return = int(options.dagman_return)
if len(tuple(option for option in (options.segwizard_segments, options.gps_segment_list, options.gps_start_time) if bool(option))) != 1:
raise ValueError, "must supply exactly one of --segwizard-segments, or --gps-segment-list, or both --gps-start-time and --gps-end-time"
if bool(options.gps_start_time) ^ bool(options.gps_end_time):
raise ValueError, "cannot set only one of --gps-start-time and --gps-end-time"
if options.segwizard_segments:
options.segs = segmentsUtils.fromsegwizard(file(options.segwizard_segments), coltype = LIGOTimeGPS).coalesce()
elif options.gps_segment_list:
options.segs = segmentsUtils.from_range_strings(options.gps_segment_list.split(","), boundtype = LIGOTimeGPS)
elif options.gps_start_time and options.gps_end_time:
options.segs = segments.segmentlist([segments.segment(LIGOTimeGPS(options.gps_start_time), LIGOTimeGPS(options.gps_end_time))])
else:
# should not get here
raise ValueError, "oops, script error: please report to author"
return options, (filenames or [None])
try:
options, filenames = parse_command_line()
except ValueError, e:
write_error_lines([str(e)])
sys.exit(1)
#
# =============================================================================
#
# Dagman Helper
#
# =============================================================================
#
#
# The idea here is that LSCdataFindcheck is designed to be added as a post
# script on an LSCdataFind DAG node in a Condor dagman application. To
# support this usage, it's necessary for the post script to propogate any
# error codes the LSCdataFind reports, and so this program has the
# --dagman-return command line option. In a Condor .dag file, the post
# script's command line options should include "--dagman-return $RETURN".
# dagman will replace "$RETURN" with the ASCII representation of the
# LSCdataFind's return code, which this program then returns as its result.
#
if options.dagman_return:
write_error_lines(["dag job execution failed"])
sys.exit(options.dagman_return)
#
# =============================================================================
#
# Main
#
# =============================================================================
#
#
# loop over LAL cache files
#
for filename in filenames:
#
# parse file into a list of CacheEntry objects
#
if filename is not None:
cache = [CacheEntry(line) for line in file(filename)]
else:
cache = [CacheEntry(line) for line in sys.stdin]
#
# check that the cache spans the requested segment(s)
#
seglist = segments.segmentlist([c.segment for c in cache]).coalesce()
if options.segs - seglist:
write_error_lines(["%s does not span:" % (filename or "stdin"), options.segs, "missing:", options.segs - seglist])
sys.exit(1)
#
# check that the files spanning the desired segment(s) are
# accessible. only local files that intersect the requested
# segmentlist are tested
#
if options.stat:
badpaths = [c.path() for c in cache if options.segs.intersects_segment(c.segment) and c.host().lower() in ("", "localhost") and not os.access(c.path(), os.R_OK)]
if badpaths:
write_error_lines(["%s lists inaccessible files:" % (filename or "stdin"), badpaths])
sys.exit(1)
#
# all OK
#
sys.exit(0)
#!/usr/bin/python
"""
LSCfileAdd
a tool to add files into an LDR instance.
Written by Ben Johnson
and is based on python (un)publishing routines by Hari Pulapaka,
as well as the LSCdataFind code.
This file last edited on Thu Oct 07 15:43:27 PDT 2004 @988 /Internet Time/
TODO: Must define exceptions better, and of course, get it to work at all...
This program is part of the Grid LSC User Environment (GLUE)
GLUE is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
__author__="Ben Johnson: publishes file lfn<->pfn mappings and associated metadata into a database"
__date__='$Date$'
__version__='$Revision$'[0:0]
import exceptions
import sys
#try:
# from pyGlobus import security
#except ImportError:
# print >>sys.stderr, "\nCould not import a module from the pyGlobus library."
# print >>sys.stderr, "\nPlease run your LSC Data Grid setup script:"
# print >>sys.stderr, " e.g. prompt> . ~/ldg-3.0/setup.sh # for the bash shell"
# print >>sys.stderr, " prompt> source ~/ldg-3.0/setup.csh # for (t)csh"
# print >>sys.stderr, "\n or point your PYTHONPATH environment variable to the location of the pyGlobus modules."
# sys.exit(1)
try:
from glue.LSCfileAdd import *
except ImportError, e:
print >>sys.stderr, e
print >>sys.stderr, "\nPython LSCfileAdd.py library is not found; please add its location to the PYTHONPATH environmental variable."
print >>sys.stderr, "\nFor example, from the bash or (t)csh shell respectively, run:\n"
print >>sys.stderr, " export PYTHONPATH=$PYTHONPATH:$LSCSOFT/src/glue/lib"
print >>sys.stderr, "or"
print >>sys.stderr, " setenv PYTHONPATH ${PYTHONPATH}:$LSCSOFT/src/glue/lib"
print >>sys.stderr, "\nwhere $LSCSOFT is the directory containing the lscsoft cvs repository."
sys.exit(1)
def print_stats(successes,failures):
"""
Prints what was done by the LSCfileAdd. i.e. the names of each file
And the effective metadata that was added to the database etc.
"""
print "Publishing finished"
print "Successfully published filenames:"
for item in successes:
print "\t%s" % (item,)
print "Filenames which failed to be published (plus reason):"
for item in failures:
print "\t%s\n\t\t%s" % (item[0],item[1])
print "Total files successfully published: %s" % (len(successes),)
print "Total files which were not published: %s" % (len(failures),)
## END print_stats()
##### Begin Main #####
if __name__ == '__main__':
# Init class instances
files = LSCFile()
userparams = CLIUtil()
grid = GridUtil()
# Process command line
#try:
userparams.get_user_parameters()
#except:
# print >>sys.stderr, "Error in get_user_parameters()"
# sys.exit(1)
# Make sure the user grid credentials are ok.
#try:
# grid.checkCredentials()
#except:
# print >>sys.stderr, "Grid credentials error"
# sys.exit(2)
#Publish the files with the metadata requested
try:
files.publish(userparams.attr, userparams.filelist,\
userparams.urlType,userparams.host,userparams.port)
except LSCfileAddException, e:
print >>sys.stderr, "Error while publishing: %s" % e
sys.exit(3)
# Print what was done to stdout and exit
if userparams.nonmetaparam.has_key('verbose'):
print_stats(files.successes,files.failures)
sys.exit(0)
##### END Main #####
#!/usr/bin/python
"""
Client for querying a LSCsegFindServer to find state segments.
Uses pyGlobus and the LSCsegFindClient modules.
$Id$
"""
__version__ = '$Revision$'[11:-2]
import sys
import os
import getopt
import re
import exceptions
from types import *
try:
from glue import segments
from glue import LSCsegFindClient
from glue import gsiserverutils
from glue.lal import LIGOTimeGPS
except ImportError, e:
print >> sys.stderr, """
Error: unable to import modules from glue.
Check that glue is correctly installed and in your PYTHONPATH.
%s
""" % e
sys.exit(1)
def usage():
"""
Print a usage message to stderr.
"""
msg = """\
NAME
LSCsegFind
SYNOPSIS
LSCsegFind --server=NAME:PORT --interferometer=NAME --type=NAME
--gps-start-time=GPS --gps-end-time=GPS [ --strict-off ]
[ --output-format (tcl|python|segwizard) ]
LSCsegFind --server=NAME:PORT --show-interferometers
LSCsegFind --server=NAME:PORT --show-types
LSCsegFind --server=NAME:PORT --explain-types
LSCsegFind --server=NAME:PORT --ping
LSCsegFind --server=NAME:PORT --version
LSCsegFind --server=NAME:PORT --help
DESCRIPTION
Query a LSCsegFindServer to obtain state vector information from a
certain instrument and of a particular frame type within a GPS range.
-v, --version
Print version information for LSCdsegFind client.
-i, --interferometer
Comma separated list of interferometer names. The
intersection of segments from each interferometer is
returned. Use --show-interferometers to see what is
available.
-t, --type
Comma separated list of interferometer states. The
union of segments from all types specified is
returned. Use --show-types to see what is available.
-s, --gps-start-time
Start of GPS time range.
-e, --gps-end-time
End of GPS time range.
-r, --server
Hostname and optional port of server to query, in the form
host:port
-w, --show-interferometers
List available interferometer names.
-y, --show-types
List available segment types.
-x, --explain-types
Explain the meanings of available segment types.
-S, --strict-off
The default behavior is to truncate segments so that
returned segments are entirely in the interval
[gps-start-time, gps-end-time). However if this option
is given, the entire non-truncated segment is returned
if any part of it overlaps the interval.
-o, --output-format (tcl|python|segwizard)
Return the segments as a TCL list, a python list or in
segwizard format. If not specified the default is two
space separated columns containing segment start and
end times.
-p, --ping
Ping the LSCsegFind server.
-h, --help
Show this usage message.
ENVIRONMENT
LSC_SEGFIND_SERVER can be set to avoid having to use the
--server option on the command line.
EXAMPLES
[user@host]$ LSCsegFind --server ldas-cit.ligo.caltech.edu --show-types
Commissioning_Up
Commissioning_Up_PSL_Error
Injection
Science
Science_Conlog
Science_Loss
Science_Up
[user@host]$ LSCsegFind --server=ldas.ligo-la.caltech.edu --interferometer L1 --type Science --gps-start-time 793756813 --gps-end-time 793802413
793756813 793761885
793763207 793767231
793767680 793784113
793784732 793787382
793788056 793796486
\
"""
print >>sys.stderr, msg
# grab command line options
shortop = "vi:t:s:e:r:wxySlo:ph"
longop = [
"version",
"interferometer=",
"type=",
"gps-start-time=",
"gps-end-time=",
"server=",
"show-interferometers",
"show-types",
"explain-types",
"strict-off",
"ping",
"output-format=",
"help" ]
try:
opts, args = getopt.getopt(sys.argv[1:], shortop, longop)
except getopt.GetoptError:
print >>sys.stderr, "Error parsing command line"
print >>sys.stderr, "Enter 'LSCsegFind --help' for usage"
sys.exit(1)
# defaults
hostPortString = None
port = 30015
clientMethodArgDict = {
'interferometer': None,
'type': None,
'explain': None,
'end': None,
'start': None,
'strict' : True
}
# default method
clientMethod = 'findStateSegments'
typeString = None
format = None
# environment variables override defaults but not
# command line options
try:
hostPortString = os.environ['LSC_SEGFIND_SERVER']
except:
pass
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit(0)
elif o in ("-v", "--version"):
print 'LSCsegFind client version', __version__
import glue.LSCsegFindClient
print 'Built on top of LSCsegFindClient version', \
glue.LSCsegFindClient.version()
sys.exit(0)
elif o in ("-i", "--interferometer"):
clientMethodArgDict['interferometer'] = a
elif o in ("-t", "--type"):
clientMethodArgDict['type'] = a
elif o in ("-s", "--gps-start-time"):
clientMethodArgDict['start'] = str(LIGOTimeGPS(a).seconds)
elif o in ("-e", "--gps-end-time"):
a = LIGOTimeGPS(a)
if a.nanoseconds:
clientMethodArgDict['end'] = str(a.seconds + 1)
else:
clientMethodArgDict['end'] = str(a.seconds)
elif o in ("-r", "--server"):
hostPortString = a
elif o in ("-p", "--ping"):
clientMethod = 'ping'
elif o in ("-w", "--show-interferometers"):
clientMethod = 'showInterferometers'
elif o in ("-y", "--show-types"):
clientMethod = 'showTypes'
elif o in ("-y", "--explain-types"):
clientMethod = 'explainTypes'
elif o in ("-S", "--strict-off"):
clientMethodArgDict['strict'] = False
elif o in ("-o", "--output-format"):
format = a
if not clientMethod:
print >>sys.stderr, "Bad combination or missing options"
print >>sys.stderr, "Enter 'LSCsegFind --help' for usage"
sys.exit(1)
# determine server and port
if not hostPortString:
print >>sys.stderr, "No LSCsegFindServer specified"
print >>sys.stderr, "Enter 'LSCsegFind --help' for usage"
sys.exit(1)
if hostPortString.find(':') < 0:
# no port specified
host = hostPortString
else:
# server and port specified
host, portString = hostPortString.split(':')
port = int(portString)
# open connection to LSCsegFindServer
try:
myClient = LSCsegFindClient.LSCsegFind(host, port)
except Exception, e:
print >>sys.stderr, \
"Unable to connect to LSCsegFindServer %s:%d" % (host, port)
if gsiserverutils.checkCredentials():
print >>sys.stderr, "Got the following error : " + str(e)
print >>sys.stderr, "Enter 'LSCsegFind --help' for usage"
sys.exit(1)
try:
seglist = eval("myClient.%s(%s)" % (clientMethod, clientMethodArgDict))
if type(seglist) is StringType:
print seglist
else:
if len( seglist ) == 0:
print >> sys.stderr, "No segments found!"
else:
if not format:
for seg in seglist:
print seg[0], seg[1]
elif format == 'segwizard':
i = 0
for seg in seglist:
print i,seg[0],seg[1],abs(seg)
i += 1
elif format == 'tcl' or format == 'python':
if format == 'tcl':
ldelim = '{ '
rdelim = ' }'
cdelim = ' '
else:
ldelim = '['
rdelim = ']'
cdelim = ', '
s = seglist.pop(0)
print ldelim + ldelim + str(s[0]) + cdelim + \
str(s[1]) + rdelim,
for seg in seglist:
print cdelim + ldelim + str(seg[0]) + cdelim + \
str(seg[1]) + rdelim,
print rdelim
else:
msg = "Error: unknown segment format : %s" % format
raise LSCsegFindClient.LSCsegFindException, msg
except Exception, e:
print >>sys.stderr, "Error querying LSCsegFindServer: %s" % str(e)
print >>sys.stderr, "Enter 'LSCsegFind --help' for usage"
sys.exit(1)
sys.exit(0)
#!/usr/bin/python
"""
Client for querying a LSCsegFindServer to find state segments.
Uses pyGlobus and the LSCsegFindClientDev modules.
$Id$
"""
__version__ = '$Revision$'[11:-2]
import sys
import os
import getopt