示例#1
0
 def __init__(self, localCluster=None, **kw):
     Logger.__init__(self, kw)
     if localCluster in (None, NotSet):
         localCluster = clusterManagerConf()
     self.localCluster = AvailableManager.retrieve(localCluster)
     if self.localCluster is ClusterManager.LSF:
         self.prefix = LSFArgumentParser.prefix
         prog = 'bsub'
     elif self.localCluster is ClusterManager.PBS:
         self.prefix = PBSJobArgumentParser.prefix
         from socket import gethostname
         prog = 'qsub'
         # Work on environment
         if "service1" in gethostname():
             import re
             THEANO_FLAGS = os.getenv('THEANO_FLAGS')
             m = re.search('cxx=([^,]*)(,*)?', THEANO_FLAGS)
             if m:
                 CXX_THEANO_FLAGS = m.group(1)
                 os.environ['THEANO_FLAGS'] = re.sub(
                     'cxx=[^,]*', "cxx=ssh service1 " + CXX_THEANO_FLAGS,
                     THEANO_FLAGS)
                 self._debug("Set THEANO_FLAGS to: %s",
                             os.getenv('THEANO_FLAGS'))
             else:
                 self._warning("THEANO FLAGS continues equal to: %s",
                               os.getenv('THEANO_FLAGS'))
     else:
         self._fatal(
             "Not implemented LocalClusterNamespace for cluster manager %s",
             AvailableManager.retrieve(self.localCluster),
             NotImplementedError)
     JobSubmitNamespace.__init__(self, prog=prog)
示例#2
0
 def __init__(self, transientAttrs = set(), toPublicAttrs = set(), **kw):
   "Initialize streamer and declare transient variables."
   Logger.__init__(self, kw)
   self.transientAttrs = set(transientAttrs) | {'_readVersion',}
   self.toPublicAttrs = set(toPublicAttrs)
   from RingerCore.util import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
示例#3
0
 def __init__(self, transientAttrs = set(), toPublicAttrs = set(), **kw):
   "Initialize streamer and declare transient variables."
   Logger.__init__(self, kw)
   self.transientAttrs = set(transientAttrs) | {'_readVersion',}
   self.toPublicAttrs = set(toPublicAttrs)
   from RingerCore.Configure import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
示例#4
0
  def __init__(self, *args, **kw):
    """
      Set values using min:incr:max and matlabFlag as explained in class
      documentation.
    """
    from RingerCore.Configure import checkForUnusedVars
    Logger.__init__(self, kw)
    self._matlabFlag = kw.pop('matlabFlag', False )
    checkForUnusedVars( kw, self._warning )
    del kw

    if len(args) > 3: 
      raise ValueError("Input more than 3 values, format should be [min=0:[incr=1:]]max")

    if len(args) == 0 or (args[0] in ([],tuple(),)): 
      # Create empty looping bounds
      self._vec = [0,-1,1]
      return

    if isinstance(args[0], LoopingBounds ):
      self._vec = args[0]._vec
      oldFlag = self._matlabFlag
      self._matlabFlag = args[0]._matlabFlag
      if oldFlag != self._matlabFlag:
        if self._matlabFlag:
          self.turnMatlabFlagOn()
        else:
          self.turnMatlabFlagOff()
      return
    elif isinstance(args[0], list ):
      self._vec = args[0]
    else:
      self._vec = list(args)

    if len(self._vec) == 1:
      self._vec.append( self._vec[0] + 1 )
      if not self._matlabFlag:
        self._vec[1] -= 1
      self._vec[0] = 1 if self._matlabFlag else 0
    elif len(self._vec) == 2:
      if self._matlabFlag: 
        self._vec[1] += 1
    else:
      tmp = self._vec[1]
      if self._matlabFlag:
        if tmp > 0:
          self._vec[1] = self._vec[2] + 1
        else:
          self._vec[1] = self._vec[2] - 1
      else:
        self._vec[1] = self._vec[2]
      self._vec[2] = tmp

    if len(self._vec) == 3 and self._vec[2] == 0:
      raise ValueError("Attempted to create looping bounds without increment.")
示例#5
0
    def __init__(self, outputFile, **kw):
        Logger.__init__(self, kw)
        if not outputFile.endswith(".root"):
            outputFile += ".root"
        # Create TFile object to hold everything
        from ROOT import TFile

        self._file = TFile(outputFile, "recreate")
        self._currentDir = ""
        self._objects = dict()
        self._dirs = list()
示例#6
0
 def __init__(self, **kw):
   Logger.__init__(self, kw)
   self.__useFortran = kw.pop( 'useFortran', False )
   self.order          = 'F' if self.__useFortran else 'C'
   self.pdim           = 0   if self.__useFortran else 1
   self.odim           = 1   if self.__useFortran else 0
   self.fp_dtype       = np.dtype( kw.pop( 'fp_dtype',       np.float64 ) )
   self.int_dtype      = np.dtype( kw.pop( 'int_dtype',      np.int64   ) )
   self.scounter_dtype = np.dtype( kw.pop( 'scounter_dtype', np.uint8   ) )
   self.flag_dtype     = np.dtype( kw.pop( 'flag_dtype',     np.int8    ) )
   checkForUnusedVars(kw)
示例#7
0
 def __init__(self, **kw):
     Logger.__init__(self, kw)
     self.__useFortran = kw.pop('useFortran', False)
     self.order = 'F' if self.__useFortran else 'C'
     self.pdim = 0 if self.__useFortran else 1
     self.odim = 1 if self.__useFortran else 0
     self.fp_dtype = np.dtype(kw.pop('fp_dtype', np.float64))
     self.int_dtype = np.dtype(kw.pop('int_dtype', np.int64))
     self.scounter_dtype = np.dtype(kw.pop('scounter_dtype', np.uint8))
     self.flag_dtype = np.dtype(kw.pop('flag_dtype', np.int8))
     checkForUnusedVars(kw)
示例#8
0
  def __init__(self, *args, **kw):
    """
      Set values using min:incr:max and matlabFlag as explained in class
      documentation.
    """
    from RingerCore.util import checkForUnusedVars
    Logger.__init__(self, kw)
    self._matlabFlag = kw.pop('matlabFlag', False )
    checkForUnusedVars( kw, self._logger.warning )
    del kw

    if len(args) > 3: 
      raise ValueError("Input more than 3 values, format should be [min=0:[incr=1:]]max")

    if len(args) == 0: 
      raise ValueError("No input. Format should be [min=0,[incr=1,]]max")

    if isinstance(args[0], LoopingBounds ):
      self._vec = args[0]._vec
      oldFlag = self._matlabFlag
      self._matlabFlag = args[0]._matlabFlag
      if oldFlag != self._matlabFlag:
        if self._matlabFlag:
          self.turnMatlabFlagOn()
        else:
          self.turnMatlabFlagOff()
      return
    elif isinstance(args[0], list ):
      self._vec = args[0]
    else:
      self._vec = list(args)

    if len(self._vec) == 1:
      self._vec.append( self._vec[0] + 1 )
      if not self._matlabFlag:
        self._vec[1] -= 1
      self._vec[0] = 1 if self._matlabFlag else 0
    elif len(self._vec) == 2:
      if self._matlabFlag: 
        self._vec[1] += 1
    else:
      tmp = self._vec[1]
      if self._matlabFlag:
        if tmp > 0:
          self._vec[1] = self._vec[2] + 1
        else:
          self._vec[1] = self._vec[2] - 1
      else:
        self._vec[1] = self._vec[2]
      self._vec[2] = tmp

    if len(self._vec) == 3 and self._vec[2] == 0:
      raise ValueError("Attempted to create looping bounds without increment.")
示例#9
0
 def __init__(self, ignoreAttrs = set(), toProtectedAttrs = set(), ignoreRawChildren = False, **kw ):
   """
     -> ignoreAttrs: not consider this attributes on the dictionary values.
     -> toProtectedAttrs: change public attributes to protected or private
       attributes. That is, suppose the dictionary value is 'val' and the class
       value should be _val or __val, then add toProtectedAttrs = ['_val'] or
       '__val'.
     -> ignoreRawChildren: Do not attempt to conver raw children to higher level object.
   """
   Logger.__init__(self, kw)
   ignoreAttrs = list(set(ignoreAttrs) | RawDictCnv.baseAttrs)
   import re
   self.ignoreAttrs = [re.compile(ignoreAttr) for ignoreAttr in ignoreAttrs]
   self.toProtectedAttrs = set(toProtectedAttrs)
   self.ignoreRawChildren = ignoreRawChildren
   from RingerCore.util import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
示例#10
0
 def __init__(self, ignoreAttrs = set(), toProtectedAttrs = set(), ignoreRawChildren = False, **kw ):
   """
     -> ignoreAttrs: not consider this attributes on the dictionary values.
     -> toProtectedAttrs: change public attributes to protected or private
       attributes. That is, suppose the dictionary value is 'val' and the class
       value should be _val or __val, then add toProtectedAttrs = ['_val'] or
       '__val'.
     -> ignoreRawChildren: Do not attempt to conver raw children to higher level object.
   """
   Logger.__init__(self, kw)
   ignoreAttrs = list(set(ignoreAttrs) | RawDictCnv.baseAttrs)
   import re
   self.ignoreAttrs = [re.compile(ignoreAttr) for ignoreAttr in ignoreAttrs]
   self.toProtectedAttrs = set(toProtectedAttrs)
   self.ignoreRawChildren = ignoreRawChildren
   from RingerCore.Configure import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
示例#11
0
 def __init__(self, d={}, **kw):
     if None in self._contextManager._acceptedTypes:
         self._contextManager._acceptedTypes = TexObject,
     if (not isinstance(self, TexObjectCollection)
             and not hasattr(self, '_preamble')
             and not hasattr(self, '_enclosure')
             and not hasattr(self, '_body')
             and not hasattr(self, '_footer')
             and not hasattr(self, '_appendix')):
         raise TexException(
             self, 'Class %s does not write any tex code.' %
             self.__class__.__name__)
     d.update(kw)
     Logger.__init__(self, d)
     if hasattr(self, '_body'):
         self._body = formatTex(self._body, retrieve_kw(d, 'textWidth', 80))
     self._stream = kw.pop('stream', tss)
     self._keywords = {
         key: val
         for key, val in d.iteritems() if not key.startswith('_')
     }
     self._keywords.update({
         key: val
         for key, val in self.__dict__.iteritems()
         if not key.startswith('_')
     })
     if 'star' in self._keywords and self._keywords['star']:
         self._keywords['star'] = '*'
     else:
         self._keywords['star'] = ''
     if hasattr(self, '_assertVars'):
         for key in self._assertVars:
             if not key in self._keywords:
                 raise TexException(self, "Assert var %s failed." % key)
     gcc.set(self)
     self._contextManaged = d.pop('_contextManaged', True)
     self._context = self._contextManager()
     self._isInContext = self._context is not None
     if (self._isInContext
             and isinstance(self._context, TexObjectCollection)
             and self._contextManaged):
         self._context += self
     if self._isInContext:
         self._stream = self._context._stream
示例#12
0
 def __init__(self, prog=None, **kw):
     Logger.__init__(self, kw)
     if prog is not None:
         self.prog = prog
     else:
         try:
             self.prog = self.__class__.prog
         except AttributeError:
             raise AttributeError(
                 "Not specified class (%s) prog attribute!" %
                 self.__class__.__name__)
     if not hasattr(self, 'prefix'):
         try:
             self.prefix = self.__class__.ParserClass.prefix
         except AttributeError:
             raise AttributeError(
                 "Not specified class (%s) ParserClass attribute!" %
                 self.__class__.__name__)
     argparse.Namespace.__init__(self)
     self.fcn = os.system
  def __init__(self, tes, **kw):
    Logger.__init__( self, **kw )
    import logging
    self.baseDir        = kw.pop('baseDir','')
    self.bucketName     = kw.pop('bucketName','')
    self.pidName        = kw.pop('pidName','tight')
    self._level         = kw.pop('level',logging.INFO)
    self.appName        = kw.pop('appName','TrigAnalysisTool')
    checkForUnusedVars(kw)
    del kw

    self._logger.info('Start wrapper between python and c++ core.')
    
    self._trigAnalysisTool = ROOT.TrigAnalysisTool(self.appName,
                                                   self.bucketName,
                                                   self.baseDir,
                                                   self.pidName,
                                                   self._level)
    for te in tes:
      self._trigAnalysisTool.push_back( te() )

    self._logger.info('TrigAnalysisTool has been created.' )
示例#14
0
 def __init__(self, **kw):
     self._choice = NotSet
     if not hasattr(self, 'name'):
         self.name = self.__class__.__name__.lstrip('_')
         self.name = self.name.replace('Configure', '')
     Logger.__init__(self, kw, logName=self.name)
示例#15
0
 def __init__(self, outputFile):
     Logger.__init__(self)
     from RingerCore.FileIO import ensureExtension
     if not outputFile:
         raise TexException(self, 'Cannot stream to empty file path.')
     self.outputFile = ensureExtension(outputFile, self._outputExtension)
示例#16
0
 def __init__(self, d = {}, **kw): 
   Logger.__init__(self, d, **kw)
示例#17
0
 def __init__(self, d = {}, **kw): 
   Logger.__init__(self, d, **kw)
示例#18
0
 def __init__(self, prog = 'prun', **kw):
   Logger.__init__( self, kw )
   LoggerNamespace.__init__( self, **kw )
   self.prog = prog