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

Diff for /JSOC/localize.py between version 1.3 and 1.4

version 1.3, 2013/11/11 14:53:11 version 1.4, 2013/11/11 15:40:14
Line 170  def processMakeParam(mDefs, key, val, pl
Line 170  def processMakeParam(mDefs, key, val, pl
                 machDict[varMach] = {}                 machDict[varMach] = {}
             machDict[varMach][varName] = varValu             machDict[varMach][varName] = varValu
  
 def processParam(cfgfile, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section):  def processParam(cfgfile, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section):
     status = 0     status = 0
  
     matchobj = regexpComm.match(line)     matchobj = regexpComm.match(line)
Line 239  def processParam(cfgfile, line, regexpCo
Line 239  def processParam(cfgfile, line, regexpCo
                     raise Exception('paramNameTooLong', key)                     raise Exception('paramNameTooLong', key)
  
                 # Make file - val should never be quoted; just use as is                 # Make file - val should never be quoted; just use as is
                 mDefs.extend(list('\n' + key + ' = ' + val))                  mDefsGen.extend(list('\n' + key + ' = ' + val))
  
                 # Perl file - val should ALWAYS be single-quote quoted                 # Perl file - val should ALWAYS be single-quote quoted
                 # Save const info to a string                 # Save const info to a string
Line 267  def processParam(cfgfile, line, regexpCo
Line 267  def processParam(cfgfile, line, regexpCo
  
             # This information is for making make variables only. We do not need to worry about quoting any values             # This information is for making make variables only. We do not need to worry about quoting any values
             defs[key] = val             defs[key] = val
             processMakeParam(mDefs, key, val, platDict, machDict)              processMakeParam(mDefsMake, key, val, platDict, machDict)
  
     return bool(0)     return bool(0)
  
 # We have some extraneous line or a newline - ignore. # We have some extraneous line or a newline - ignore.
  
 # defs is a dictionary containing all parameters (should they be needed in this script) # defs is a dictionary containing all parameters (should they be needed in this script)
 def parseConfig(fin, keymap, addenda, defs, cDefs, mDefs, perlConstSection, perlInitSection):  def parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection):
     rv = bool(0)     rv = bool(0)
  
     # Open required config file (config.local)     # Open required config file (config.local)
Line 294  def parseConfig(fin, keymap, addenda, de
Line 294  def parseConfig(fin, keymap, addenda, de
         iscfg = bool(1)         iscfg = bool(1)
         if not fin is None:         if not fin is None:
             for line in fin:             for line in fin:
                 ppRet = processParam(iscfg, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section)                  ppRet = processParam(iscfg, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)
                 if ppRet:                 if ppRet:
                     break;                     break;
  
Line 303  def parseConfig(fin, keymap, addenda, de
Line 303  def parseConfig(fin, keymap, addenda, de
         iscfg = bool(0)         iscfg = bool(0)
         for key in addenda:         for key in addenda:
             item = key + ' ' + addenda[key]             item = key + ' ' + addenda[key]
             ppRet = processParam(iscfg, item, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section)              ppRet = processParam(iscfg, item, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)
             if ppRet:             if ppRet:
                 break;                 break;
     except Exception as exc:     except Exception as exc:
Line 328  def parseConfig(fin, keymap, addenda, de
Line 328  def parseConfig(fin, keymap, addenda, de
             # re-raise the exception             # re-raise the exception
             raise             raise
  
     # Put information collected in platDict and machDict into mDefs      # Put information collected in platDict and machDict into mDefs. Must do this here, and not in processParam, since
       # we need to parse all platform-specific make variables before grouping them into platform categories.
     if not rv:     if not rv:
         for plat in platDict:         for plat in platDict:
             mDefs.extend(list('\nifeq ($(JSOC_MACHINE), linux_' + plat.lower() + ')'))              mDefsMake.extend(list('\nifeq ($(JSOC_MACHINE), linux_' + plat.lower() + ')'))
             for var in platDict[plat]:             for var in platDict[plat]:
                 mDefs.extend(list('\n' + var + ' = ' + platDict[plat][var]))                  mDefsMake.extend(list('\n' + var + ' = ' + platDict[plat][var]))
             mDefs.extend(list('\nendif\n'))              mDefsMake.extend(list('\nendif\n'))
  
     if not rv:     if not rv:
         for mach in machDict:         for mach in machDict:
             mDefs.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))              mDefsMake.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))
             for var in platDict[plat]:             for var in platDict[plat]:
                 mDefs.extend(list('\n' + var + ' = ' + platDict[plat][var]))                  mDefsMake.extend(list('\n' + var + ' = ' + platDict[plat][var]))
             mDefs.extend(list('\nendif\n'))              mDefsMake.extend(list('\nendif\n'))
  
     return rv     return rv
  
Line 483  def configureComps(defs, mDefs):
Line 484  def configureComps(defs, mDefs):
  
     return rv     return rv
  
 def writeFiles(base, cfile, mfile, pfile, cDefs, mDefs, perlConstSection, perlInitSection):  def writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection):
     rv = bool(0)     rv = bool(0)
  
       # Merge mDefsGen, mDefsMake, and mDefsComps into a single string with compiler configuration first, general parameters next, then
       # make-specific make variables (e.g., third-party library information) last.
       mDefs = '\n# Compiler Selection\n' + ''.join(mDefsComps) + '\n\n# General Parameters\n' + ''.join(mDefsGen) + '\n\n# Parameters to Configure make\n' + ''.join(mDefsMake)
   
     try:     try:
         with open(cfile, 'w') as cout, open(mfile, 'w') as mout, open(pfile, 'w') as pout:         with open(cfile, 'w') as cout, open(mfile, 'w') as mout, open(pfile, 'w') as pout:
             # C file of macros             # C file of macros
Line 499  def writeFiles(base, cfile, mfile, pfile
Line 504  def writeFiles(base, cfile, mfile, pfile
  
             # Make file of make variables             # Make file of make variables
             print(PREFIX, file=mout)             print(PREFIX, file=mout)
             print('# This file contains a set of make-variable values - one for each configuration parameter.', file=mout)              print('# This file contains a set of make-variable values. The first section contains compiler-selection variables, the second contains general configuration variables, and the third section contains variables that configure how make is run.', file=mout)
             print(''.join(mDefs), file=mout)              print(mDefs, file=mout)
  
             # Perl module             # Perl module
             print(PERL_BINPATH, file=pout)             print(PERL_BINPATH, file=pout)
Line 529  def configureNet(cfgfile, cfile, mfile,
Line 534  def configureNet(cfgfile, cfile, mfile,
     defs = {}     defs = {}
     cDefs = list()     cDefs = list()
     mDefs = list()     mDefs = list()
       mDefsGen = list()
       mDefsMake = list()
       mDefsComps = list()
     perlConstSection = list()     perlConstSection = list()
     perlInitSection = list()     perlInitSection = list()
     addenda = {}     addenda = {}
Line 545  def configureNet(cfgfile, cfile, mfile,
Line 553  def configureNet(cfgfile, cfile, mfile,
     try:     try:
         with open(cfgfile, 'r') as fin:         with open(cfgfile, 'r') as fin:
             # Process configuration parameters             # Process configuration parameters
             rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefs, perlConstSection, perlInitSection)              rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection)
             if rv == bool(0):             if rv == bool(0):
                 # 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
Line 553  def configureNet(cfgfile, cfile, mfile,
Line 561  def configureNet(cfgfile, cfile, mfile,
                 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, mDefs, perlConstSection, perlInitSection)                      rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, perlConstSection, perlInitSection)
  
             # Configure the compiler-selection make variables.             # Configure the compiler-selection make variables.
             if rv == bool(0):             if rv == bool(0):
                 rv = configureComps(defs, mDefs)                  rv = configureComps(defs, mDefsComps)
  
             # Write out the parameter files.             # Write out the parameter files.
             if rv == bool(0):             if rv == bool(0):
                 rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefs, perlConstSection, perlInitSection)                  rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection)
     except IOError as exc:     except IOError as exc:
         sys.stderr.write(exc.strerror)         sys.stderr.write(exc.strerror)
         sys.stderr.write('Unable to read configuration file ' + cfgfile + '.')         sys.stderr.write('Unable to read configuration file ' + cfgfile + '.')


Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

Karen Tian
Powered by
ViewCVS 0.9.4