(file) Return to localize.py CVS log (file) (dir) Up to [Development] / JSOC

Diff for /JSOC/localize.py between version 1.28 and 1.32

version 1.28, 2020/02/04 20:57:26 version 1.32, 2022/06/06 23:13:28
Line 1 
Line 1 
 #!/usr/bin/python3  #!/usr/bin/env python
  
 # When run with the -s flag, localize.py configures the SUMS-server component of NetDRMS. # When run with the -s flag, localize.py configures the SUMS-server component of NetDRMS.
 import sys import sys
Line 74  PERL_FXNS_B = """sub get
Line 74  PERL_FXNS_B = """sub get
 } }
 1;""" 1;"""
  
 PY_BINPATH = '#!/usr/bin/python\n'  PY_BINPATH = '#!/usr/bin/env python3\n'
   
   PY_ALL = f"__all__ = [ 'DPError', 'DPMissingParameterError', 'DRMSParams' ]"
   
   PY_ERROR_CLASSES = """
   class DPError(Exception):
       def __init__(self):
           self._msg = 'DRMS Parameter Error: '
   
   class DPMissingParameterError(DPError):
       def __init__(self, parameter):
           super().__init__()
           self._msg += 'missing DRMS parameter ' + parameter
   
       def __str__(self):
           return self._msg
   """
  
 PY_FXNS_A = """ PY_FXNS_A = """
 class DRMSParams(object): class DRMSParams(object):
Line 95  PY_FXNS_B = """ def get(self, name):
Line 111  PY_FXNS_B = """ def get(self, name):
             return None             return None
 """ """
  
 PY_FXNS_C = """    def getBool(self, name):  PY_FXNS_C = """    def get_required(self, name):
           try:
               value = self.params[name]
           except:
               raise DPMissingParameterError(name)
   
           return value
   
       def getBool(self, name):
         if name in self.params:         if name in self.params:
             return bool(self.params[name] == '1')             return bool(self.params[name] == '1')
         else:         else:
             return None             return None
   
       def __getattr__(self, name):
           # only called if object.__getattribute__(self, name) raises; and if that is true, then we want
           # to look in self.params for it, and set the instance attribute if it does exist in self.params
           if name in self.params:
               attr = self.params[name]
               self.__setattr__(name, attr)
           else:
               attr = None
   
           return attr
   
       def __setattr__(self, name, value):
           # call neither __setattr__ nor __getattr__
           try:
               params = object.__getattr__(self, 'params')
   
               # put into self.params dict, overwriting if necessary
               params[name] = value
           except:
               pass
   
           # store in instance dict as well
           object.__setattr__(self, name, value)
 """ """
  
 SH_BINPATH = '#!/bin/bash\n' SH_BINPATH = '#!/bin/bash\n'
Line 800  def configureComps(defs, mDefs):
Line 848  def configureComps(defs, mDefs):
  
         if not hasicc and not hasgcc:         if not hasicc and not hasgcc:
             print('Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.', file=sys.stderr)             print('Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.', file=sys.stderr)
             rv = bool(1)              rv = bool(0) # Art - don't bail, we might be using drmsparams.py and not care about the rest of DRMS
         elif hasicc:         elif hasicc:
             mDefs.extend(list('\nCOMPILER = icc'))             mDefs.extend(list('\nCOMPILER = icc'))
             # mDefs.extend(list('\nICC_VERSION = blah'))             # mDefs.extend(list('\nICC_VERSION = blah'))
Line 862  def writeParamsFiles(base, cfile, mfile,
Line 910  def writeParamsFiles(base, cfile, mfile,
             print(PY_BINPATH, file=pyout)             print(PY_BINPATH, file=pyout)
             print(PREFIX, file=pyout)             print(PREFIX, file=pyout)
             print('# This file contains a set of constants - one for each configuration parameter.\n', file=pyout)             print('# This file contains a set of constants - one for each configuration parameter.\n', file=pyout)
               print(PY_ALL, file=pyout)
             print(''.join(pyConstSection), file=pyout)             print(''.join(pyConstSection), file=pyout)
   
               print(PY_ERROR_CLASSES, file=pyout)
             print(PY_FXNS_A, file=pyout, end='')             print(PY_FXNS_A, file=pyout, end='')
             print(''.join(pyInitSection), file=pyout)             print(''.join(pyInitSection), file=pyout)
             print(PY_FXNS_B, file=pyout)             print(PY_FXNS_B, file=pyout)
Line 1084  def configureNet(cfgfile, cfile, mfile,
Line 1135  def configureNet(cfgfile, cfile, mfile,
                 # Must add a parameter for the SUMS_MANAGER UID (for some reason). This must be done after the                 # Must add a parameter for the SUMS_MANAGER UID (for some reason). This must be done after the
                 # config file is processed since an input to getMgrUIDLine() is one of the config file's                 # config file is processed since an input to getMgrUIDLine() is one of the config file's
                 # parameter values.                 # parameter values.
   
                   # CANNOT run this unless sunroom2 home directories are accessible
                 uidParam = {}                 uidParam = {}
                 rv = getMgrUIDLine(defs, uidParam)                 rv = getMgrUIDLine(defs, uidParam)
   
                 if rv == bool(0):                 if rv == bool(0):
                     rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection, pyConstSection, pyInitSection, shConstSection)                     rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection, pyConstSection, pyInitSection, shConstSection)
   
                   # ignore the error where the SUMS manager UID cannot be determined
                   rv = 0
   
             # Configure the compiler-selection make variables.             # Configure the compiler-selection make variables.
             if not rv:             if not rv:
                 rv = configureComps(defs, mDefsComps)                 rv = configureComps(defs, mDefsComps)
Line 1180  def configureSdp(cfgfile, cfile, mfile,
Line 1238  def configureSdp(cfgfile, cfile, mfile,
                 if not rv:                 if not rv:
                     rv = parseConfig(None, None, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection, pyConstSection, pyInitSection, shConstSection)                     rv = parseConfig(None, None, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection, pyConstSection, pyInitSection, shConstSection)
  
                   # ignore the error where the SUMS manager UID cannot be determined
                   rv = 0
   
                 # Configure the compiler-selection make variables.                 # Configure the compiler-selection make variables.
                 if not rv:                 if not rv:
                     rv = configureComps(defs, mDefsComps)                     rv = configureComps(defs, mDefsComps)


Legend:
Removed from v.1.28  
changed lines
  Added in v.1.32

Karen Tian
Powered by
ViewCVS 0.9.4