version 1.27, 2017/09/13 17:46:15
|
version 1.29, 2020/08/14 17:41:25
|
|
|
#!/usr/bin/python |
#!/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. |
from __future__ import print_function |
|
import sys | import sys |
import getopt | import getopt |
import re | import re |
|
|
import xml.etree.ElementTree as ET | import xml.etree.ElementTree as ET |
from subprocess import check_output, CalledProcessError | from subprocess import check_output, CalledProcessError |
| |
if sys.version_info < (2, 7): |
|
raise Exception("You must run the 2.7 release, or a more recent release, of Python.") |
|
| |
# Constants | # Constants |
VERS_FILE = 'jsoc_version.h' | VERS_FILE = 'jsoc_version.h' |
Line 77 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 python\n' |
|
|
|
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 98 PY_FXNS_B = """ def get(self, name): |
|
Line 109 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 806 def configureComps(defs, mDefs): |
|
Line 849 def configureComps(defs, mDefs): |
|
rv = bool(1) | rv = bool(1) |
elif hasicc: | elif hasicc: |
mDefs.extend(list('\nCOMPILER = icc')) | mDefs.extend(list('\nCOMPILER = icc')) |
|
# mDefs.extend(list('\nICC_VERSION = blah')) |
else: | else: |
mDefs.extend(list('\nCOMPILER = gcc')) | mDefs.extend(list('\nCOMPILER = gcc')) |
| |
Line 865 def writeParamsFiles(base, cfile, mfile, |
|
Line 909 def writeParamsFiles(base, cfile, mfile, |
|
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(''.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) |