Beispiel #1
0
 def shutdown(self):
     g = importName(self.name, 'shutdown')
     if g:
         g()
     else:
         logger.debug(
             "no shutdown procedure in runtime package %s", self.name)
Beispiel #2
0
def _valueTypeAllowed(val, valTypeList, logger=None):
    for _t in valTypeList:
        _dotMod = _t.split(".")
        if len(_dotMod) > 1:
            if not hasattr(val, "_proxyClass"):
                # val is probably a normal Python object.
                continue
            _type = importName(".".join(_dotMod[0:-1]), _dotMod[-1])
            _val = val
        else:  # Native Python type
            try:
                if type(_t) == str:
                    global found_types
                    if not _t in found_types.keys():
                        found_types[_t] = eval(_t)
                    _type = found_types[_t]
                    # _type = eval(_t)  # '_type' is actually the class name
                else:
                    _type = _t
            except NameError:
                logger.error("Invalid native Python type: '%s'" % _t)
                continue
            _val = val
        # Deal with the case where type is None.
        if _type is None:
            if _val is None:
                return True
            else:
                continue
        elif isinstance(_val, _type):
            return True
    return False
Beispiel #3
0
 def postBootstrapHook(self):
     g = importName(self.name, 'postBootstrapHook')
     if g:
         g()
     else:
         logger.debug("no postBootstrapHook() in runtime package %s",
                      self.name)
Beispiel #4
0
 def loadPlugins(self):
     logger.debug("Loading Plugin: %s" % self.name)
     g = importName(self.name, 'loadPlugins')
     if g:
         g(self.config)
     else:
         logger.debug("no plugins defined for runtime package %s", self.name)
     logger.debug("Finished Plugin: %s" % self.name)
Beispiel #5
0
 def getEnvironment(self):
     # FIXME: pass the configuration object
     g = importName(self.name, 'getEnvironment')
     if g:
         return g(self.config)
     else:
         logger.debug("no environment defined for runtime package %s", self.name)
         return {}
Beispiel #6
0
 def shutdown(self):
     g = importName(self.name, 'shutdown')
     if g:
         g()
     else:
         from Ganga.Utility.logging import getLogger
         logger = getLogger(modulename=1)
         logger.debug("no shutdown procedure in runtime package %s", self.name)
Beispiel #7
0
 def standardSetup(self):
     """Perform any standard setup for the package"""
     g = importName(self.name, 'standardSetup')
     if g:
         return g()
     else:
         logger.debug("no standard setup defined for runtime package %s", self.name)
         return {}
Beispiel #8
0
 def standardSetup(self):
     """Perform any standard setup for the package"""
     g = importName(self.name, 'standardSetup')
     if g:
         return g()
     else:
         logger.debug("no standard setup defined for runtime package %s", self.name)
         return {}
Beispiel #9
0
 def shutdown(self):
     g = importName(self.name, 'shutdown')
     if g:
         g()
     else:
         from Ganga.Utility.logging import getLogger
         logger = getLogger(modulename=1)
         logger.debug("no shutdown procedure in runtime package %s", self.name)
Beispiel #10
0
 def loadPlugins(self):
     logger.debug("Loading Plugin: %s" % self.name)
     g = importName(self.name, 'loadPlugins')
     if g:
         g(self.config)
     else:
         logger.debug("no plugins defined for runtime package %s", self.name)
     logger.debug("Finished Plugin: %s" % self.name)
Beispiel #11
0
 def getEnvironment(self):
     # FIXME: pass the configuration object
     g = importName(self.name, 'getEnvironment')
     if g:
         return g(self.config)
     else:
         logger.debug("no environment defined for runtime package %s",
                      self.name)
         return {}
Beispiel #12
0
def _valueTypeAllowed(val, valTypeList, logger=None):
    for _t in valTypeList:

        try:
            from Ganga.GPIDev.Base.Proxy import isType
        except ImportError:
            isType = isinstance

        if not isType(_t, str) and (isclass(_t) or isType(_t, GangaObject)):
            _type = _t
            _val = val
        else:
            _dotMod = _t.split('.')
            if len(_dotMod) > 1:
                if not hasattr(val, '_proxyClass'):
                    # val is probably a normal Python object.
                    continue
                _type = importName('.'.join(_dotMod[0:-1]), _dotMod[-1])
                _val = val
            else:  # Native Python type
                try:
                    if type(_t) == str:
                        global found_types
                        if not _t in found_types.keys():
                            found_types[_t] = eval(_t)
                        _type = found_types[_t]
                        _type = eval(_t)  # '_type' is actually the class name
                    else:
                        _type = _t
                except NameError:
                    logger.error("Invalid native Python type: '%s'" % _t)
                    continue
                _val = val

        # Deal with the case where type is None.
        if _type is None:
            if _val is None:
                return True
            else:
                continue
        elif isType(_val, _type):
            return True
    return False
Beispiel #13
0
 def loadPlugins(self):
     g = importName(self.name,'loadPlugins')
     if g: g(self.config)
     else:
         logger.debug("no plugins defined for runtime package %s",self.name)
Beispiel #14
0
def _valueTypeAllowed(val, valTypeList, logger=None):
    for _t in valTypeList:

        ## Type Checking ""Should"" be proxy agnoistic but this may have problems loading before certain classes
        try:
            from Ganga.GPIDev.Base.Proxy import isType
        except ImportError:
            isType = isinstance

        ## Return None when None
        if _t is None:
            if val is None:
                return True

        if not isType(_t, str) and isclass(_t):
            _type = _t
            _val = val
        else:
            _dotMod = _t.split('.')
            if len(_dotMod) > 1:
                if not hasattr(val, '_proxyClass'):
                    # val is probably a normal Python object.
                    continue
                _type = importName('.'.join(_dotMod[0:-1]), _dotMod[-1])
                _val = val
            else:  # Native Python type
                try:
                    if type(_t) == str:
                        global found_types
                        ran_eval = False
                        try:
                            from Ganga.Base.Proxy import getRuntimeGPIObject
                        except ImportError:
                            getRuntimeGPIObject = eval
                        if not _t in found_types.keys():
                            ran_eval = True
                            found_types[_t] = getRuntimeGPIObject(_t)
                        _type = found_types[_t]
                        if ran_eval is False:
                            _type = getRuntimeGPIObject(_t)  # '_type' is actually the class name
                    else:
                        _type = _t
                except NameError:
                    logger.error("Invalid native Python type: '%s'" % _t)
                    continue
                _val = val

        try:
            from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList
            knownLists = [list, tuple, GangaList]
        except Exception as err:
            knownLists = [list, tuple]

        # Deal with the case where type is None.
        if _type is None:
            if _val is None:
                return True
            else:
                continue
        elif _type in knownLists:
            if isType(_val, knownLists):
                return True
        elif isType(_val, _type):
            return True
    return False
Beispiel #15
0
def _valueTypeAllowed(val, valTypeList, logger=None):
    for _t in valTypeList:

        ## Return None when None
        if _t is None:
            if val is None:
                return True

        if isinstance(_t, str):
            global found_types

            if _t not in found_types:
                temp = safer_eval(_t)
                if type(temp) != type(type('')):
                    temp = type(temp)
                found_types[_t] = temp
            _type = found_types[_t]

            if _type == str:
                GangaSplit = str(_t).split('.')
                if len(GangaSplit) > 1:
                    from Ganga.Utility.util import importName

                    imported_Class = importName('.'.join(GangaSplit[:-1]),
                                                GangaSplit[-1])

                    if imported_Class is not None:
                        _type = imported_Class

        else:
            _type = _t

        if isinstance(val, str):
            global found_values

            if val not in found_values:
                found_values[val] = safer_eval(val)
            _val = found_values[val]
        else:
            _val = val

        try:
            from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList
            knownLists = (list, tuple, GangaList)
        except Exception as err:
            knownLists = (list, tuple)

        # Deal with the case where type is None.
        if _type is None:
            if _val is None:
                return True
            else:
                continue

        try:
            ## Type Checking ""Should"" be proxy agnoistic but this may have problems loading before certain classes
            from Ganga.GPIDev.Base.Proxy import stripProxy
        except ImportError:
            stripProxy = dummy_func

        try:
            from Ganga.GPIDev.Base import GangaObject
        except:
            GangaObject = None

        raw_type = stripProxy(_type)
        raw_val = stripProxy(val)

        if isinstance(raw_type, GangaObject):
            return isinstance(raw_val, raw_type)

        try:
            if raw_type in knownLists:
                if isinstance(raw_val, knownLists):
                    return True
            elif isinstance(raw_val, raw_type):
                return True
        except:
            continue

    return False
Beispiel #16
0
 def postBootstrapHook(self):
     g = importName(self.name, 'postBootstrapHook')
     if g:
         g()
     else:
         logger.debug("no postBootstrapHook() in runtime package %s", self.name)
Beispiel #17
0
def _valueTypeAllowed(val, valTypeList, logger=None):
    for _t in valTypeList:

        ## Return None when None
        if _t is None:
            if val is None:
                return True

        if isinstance(_t, str):
            global found_types

            if _t not in found_types:
                temp = safer_eval(_t)
                if type(temp) != type(type('')):
                    temp = type(temp)
                found_types[_t] = temp
            _type = found_types[_t]

            if _type == str:
                GangaSplit = str(_t).split('.')
                if len(GangaSplit) > 1:
                    from Ganga.Utility.util import importName

                    imported_Class = importName( '.'.join(GangaSplit[:-1]), GangaSplit[-1])

                    if imported_Class is not None:
                        _type = imported_Class

        else:
            _type = _t
        
        if isinstance(val, str):
            global found_values

            if val not in found_values:
                found_values[val] = safer_eval(val)
            _val = found_values[val]
        else:
            _val = val

        try:
            from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList
            knownLists = (list, tuple, GangaList)
        except Exception as err:
            knownLists = (list, tuple)

        # Deal with the case where type is None.
        if _type is None:
            if _val is None:
                return True
            else:
                continue

        try:
            ## Type Checking ""Should"" be proxy agnoistic but this may have problems loading before certain classes
            from Ganga.GPIDev.Base.Proxy import stripProxy
        except ImportError:
            stripProxy = dummy_func

        try:
            from Ganga.GPIDev.Base import GangaObject
        except:
            GangaObject = None

        raw_type = stripProxy(_type)
        raw_val = stripProxy(val)

        if isinstance(raw_type, GangaObject):
            return isinstance(raw_val, raw_type)

        try:
            if raw_type in knownLists:
                if isinstance(raw_val, knownLists):
                    return True
            elif isinstance(raw_val, raw_type):
                return True
        except:
            continue

    return False