Skip to content
Snippets Groups Projects
Commit 35eaf82d authored by zimoch's avatar zimoch
Browse files

scripts moved here from utilities directory

parents
No related branches found
No related tags found
No related merge requests found
#! /usr/bin/env python
#
'''
$Source: /cvs/G/DRV/misc/App/scripts/bootinfo,v $
$Revision: 1.1 $ $Date: 2004/04/02 15:40:57 $
Obtain boot information about IOCs from the ssrm_public Oracle
database and make a pretty printout.
Usage:
-----
%s [--nocc] <pattern> [...]
where
<pattern> is used to match part of the system (i.e. crate name),
bootpc, ipaddr or ethaddr.
Unless "--nocc" is specified, <pattern> will be converted to uppercase
before being used.
Example:
%s x04sa
'''
#--------------------------------------------------------------------
import sys
import os
import urllib
import string
import getopt
import time
#---------------------------------------------------------------------------
def showUsage ():
# =========
base = os.path.basename (sys.argv[0])
print __doc__ % (base, base)
return
#---------------------------------------------------------------------------
# The program starts here!
if __name__ == "__main__":
try:
sys.stderr = sys.stdout
caseConvert = 1
#
# Analyse the options
#
(opts, items) = getopt.getopt (sys.argv[1:], "h?", \
("help", "nocc"))
for opt in opts:
if opt[0] == "-h": raise "Help"
if opt[0] == "-?": raise "Help"
if opt[0] == "--help": raise "Help"
if opt[0] == "--nocc": caseConvert = 0
#endfor
nFnd = 0
if len (items) == 0: raise "NoArgs"
#
# Loop over the list of patterns.
hdrNotDone = 1
for item in items:
if caseConvert: item = string.upper (item)
query = "SELECT SYSTEM, " + \
"BOOTDATE, " + \
"BOOTTIME, " + \
"BOOTPC, " + \
"SLSBASE, " + \
"EPICSVER AS EPICS, " + \
"VXWORKSVER AS VXWORKS, + " \
"IPADDR FROM SSRM.IOC_LASTBOOTED " + \
"WHERE SYSTEM LIKE '%" + item + "%' OR " + \
"BOOTPC LIKE '%" + item + "%' OR " + \
"SLSBASE LIKE '%" + item + "%' OR " + \
"EPICSVER LIKE '%" + item + "%' OR " + \
"VXWORKSVER LIKE '%" + item + "%' OR " + \
"IPADDR LIKE '%" + item + "%' OR " + \
"ETHADDR LIKE '%" + item + "%' OR " + \
"IPADDR LIKE '%" + item + "%' " + \
"ORDER BY SYSTEM"
url = "http://pc3839.psi.ch/testplan/IOC_INFOS/ioc_select.php?SQLQUER=" + \
urllib.quote_plus (query)
try:
ufo = urllib.urlopen (url) # Query the database
lines = ufo.readlines () # Get the result
ufo.close ()
if hdrNotDone:
toks = string.split (lines[0])
print "\n%-16s %-11s %-8s %-8s %-6s %-8s %-8s %s" % \
(toks[0], toks[1], toks[2], toks[3], toks[4], toks[5], toks[6], toks[7])
hdrNotDone = 0
else:
print
#endif
for line in lines[1:]:
nFnd = nFnd + 1
toks = string.split (line)
if len (toks) >= 8:
date = time.strptime ("%s %s" % (toks[1], toks[2]), "%d-%m-%Y %H:%M:%S")
dateStr = time.strftime ("%d-%b-%Y %H:%M:%S", date)
print "%-16s %s %-8s %-7s %-8s %-8s %s" % \
(toks[0], dateStr, toks[3], toks[4], toks[5], toks[6], toks[7])
#endif
#endfor
except:
print "\aError getting data from database!"
raise
#endtry
#endfor
if nFnd == 0: print "No database entries found!"
except getopt.error:
print "Bad option. Specify \"-h\" for help."
sys.exit (1)
except "Help":
showUsage ()
sys.exit (0)
except "NoArgs":
print "\aYou must specify a search pattern!"
sys.exit (1)
#endtry
sys.exit (0)
#endif
#--------------------------------------------------#
# emacs setup - force text mode to prevent emacs #
# from helping with the indentation! #
# Local Variables: #
# mode:text #
# indent-tabs-mode:nil #
# End: #
#--------------------------------------------------#
#
#------------------------------------------------- End of $RCSfile: bootinfo,v $
File added
#!/usr/bin/env python
#
#File: call_select.py
#Author: R.krempaska
#Description: The program should be called from bootinfo.
# It calls a ioc_select.php page which does select query as ssrm_public.
#
import httplib, sys, os, urllib
from urllib import quote_plus
sqlquery=sys.argv[1]
#print sqlquery
try:
conn=httplib.HTTP("pc3839.psi.ch")
req='/testplan/IOC_INFOS/ioc_select.php?SQLQUER='+quote_plus(sqlquery)
conn.putrequest('GET', req)
conn.endheaders()
errcode, errmsg, headers = conn.getreply()
f = conn.getfile()
data = f.read()
f.close()
print data
except:
out=open("/tmp/ioc_select.log", 'aw')
#need to write more - time of unsuccess, , author, etc
out.write(data)
out.close()
#!/bin/bash
#
# This script should only be called by the ioc at boot time.
# The startup script should have the following line:
# rsh bootHost(),"cd",SLSBASE,";sls/bin/iocBootNotice.sh",bootInfo("TendFs"),vxWorksVersion,"'",epicsRelease1,"'"
# or
# bootNotice SLSBASE,"sls/bin/iocBootNotice.sh"
if [ $# -lt 9 ]
then
echo "This script should only be called by an IOC at boot time!" >&2
exit 1
fi
#. /etc/profile
SYSTEM=$1
IPADDR=$2
PROCNUM=$3
DEVICE=$4
BOOTFILE=$5
SCRIPT=$6
VXWORKSVER=$7
EPICSVER=$8
ETHADDR=$9
if [ ! -L /ioc/$SYSTEM ]
then
echo "ERROR: $SYSTEM is not an existing system name."
echo "Rename 'target name' to your system name!"
exit 1
fi
case $SYSTEM in
( *-VME-* ) ;;
( * ) echo "ERROR: $SYSTEM is not an acceptable system name."
echo "Rename your system and 'target name' to match *-VME-*."
exit 1 ;;
esac
link=$(readlink /ioc/$SYSTEM)
SLSBASE=${link%%/iocBoot*}
BOOTPC=$(hostname -s)
if [ -L $BOOTFILE ]
then
link=$(readlink $BOOTFILE)
VXWORKS=$SLSBASE/${link##*../}
else
VXWORKS=$BOOTFILE
fi
echo "I will put the following values to the database:"
echo "SYSTEM=$SYSTEM"
echo "IPADDR=$IPADDR"
echo "PROCNUM=$PROCNUM"
echo "DEVICE=$DEVICE"
echo "BOOTPC=$BOOTPC"
echo "SLSBASE=$SLSBASE"
echo "BOOTFILE=$BOOTFILE"
echo "SCRIPT=$SCRIPT"
echo "VXWORKS=$VXWORKS"
echo "EPICSVER=$EPICSVER"
echo "VXWORKSVER=$VXWORKSVER"
echo "ETHADDR=$ETHADDR"
$SLSBASE/sls/bin/call_ioc_ins $SYSTEM $IPADDR $PROCNUM $DEVICE $BOOTPC $SLSBASE $BOOTFILE $SCRIPT $VXWORKS $EPICSVER $VXWORKSVER $ETHADDR
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment