Skip to content
Snippets Groups Projects
call_ioc_ins 4.13 KiB
Newer Older
maden's avatar
maden committed
#! /usr/bin/env python
#
#  $Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
#  $Revision: 1.3 $   $Date: 2004/07/26 09:32:34 $
maden's avatar
maden committed
'''
  Insert boot information about IOCs into the ssrm_public Oracle database.

  Usage:
  -----
    call_ioc_ins [--help] [-v] \\
          <system>     <ipadd>      <procnum>    \\
          <device>     <bootpc>     <slsbase>    \\
          <bootfile>   <script>     <vxworks>    \\
          <epicsver>   <vxworksver> <ethaddr>
  Example:
  -------
     call_ioc_ins X04SA-VME-PLD 172.19.151.29 0       \\
                  dc            pc3018        /work   \\
                  /ioc/X04SA-VME-PLD/vxWorks          \\
                  /ioc/X04SA-VME-PLD/startup.script   \\
                  /work/epics/base/bin/mv2306/vxWorks \\
                  3.13.2        5.3.1         08:00:3e:2e:78:1d
'''
#--------------------------------------------------------------------

import    sys
import    os
import    urllib
import    string
import    getopt
import    time

#--------------------------------------------------------------------

import    sys
import    os
import    urllib

#---------------------------------------------------------------------------

def showVersion ():
#   ===========
  '''
  $Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
  $Revision: 1.3 $   $Date: 2004/07/26 09:32:34 $
maden's avatar
maden committed
  Installed Location: $SLSBASE/sls/bin
  '''
  print showVersion.__doc__
  return
#---------------------------------------------------------------------------

def showUsage ():
#   =========

  print __doc__
  return

#---------------------------------------------------------------------------
#                           The program starts here!
if __name__ == "__main__":

  try:
    sys.stderr = sys.stdout
                      #
                      # Analyse the options
                      #
    force = 0
    (opts, items) = getopt.getopt (sys.argv[1:], "h?vf", \
maden's avatar
maden committed
                              ("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] == "-v":       raise "Version"
      if opt[0] == "-f":       force = 1
maden's avatar
maden committed
    #endfor
                   #######################################
                   ####
                   #### Network problems --- disable!!!
                   ####
    if not force: sys.exit (0)
                   ####
                   #######################################
maden's avatar
maden committed
    if len (items) != 12:
      print "Twelve arguments are needed, not %d" % len (items)
maden's avatar
maden committed
      sys.exit (1)
    #endif

    args = {}
    args["SYSTEM"]     = items[ 0]
    args["IPADDR"]     = items[ 1]
    args["PROCNUM"]    = items[ 2]
    args["DEVICE"]     = items[ 3]
    args["BOOTPC"]     = items[ 4]
    args["SLSBASE"]    = items[ 5]
    args["BOOTFILE"]   = items[ 6]
    args["SCRIPT"]     = items[ 7]
    args["VXWORKS"]    = items[ 8]
    args["EPICSVER"]   = items[ 9]
    args["VXWORKSVER"] = items[10]
    args["ETHADDR"]    = items[11]

    encArgs = urllib.urlencode (args)

    url = "http://pc4860.psi.ch/testplan/IOC_INFOS/ioc_boot_ins.php?" + encArgs
    try:
      ufo = urllib.urlopen (url)     # Query the database
      lines = ufo.readlines ()       # Get the result
      ufo.close ()
    except:
      print "\aError inserting data into database!"
      raise
    #endtry

  except getopt.error:
    print "Bad option. Specify \"-h\" for help."
    sys.exit (1)

  except "Help":
    showUsage ()
    sys.exit (0)

  except "Version":
    showVersion ()
    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: call_ioc_ins,v $