コード例 #1
0
ファイル: _svr_types.py プロジェクト: vinodchitrali/pbspro
    def __setattr__(self, name, value):
        if (name == "_readonly"):
            if _pbs_v1.in_python_mode() and \
                                    hasattr(self, "_readonly") and not value:
                raise BadAttributeValueError(
                    "_readonly can only be set to True!")
        elif not _resv.attributes.has_key(name):
            raise UnsetAttributeNameError("resv attribute '%s' not found" %
                                          (name, ))
        elif name in _resv.attributes_readonly and \
                                _pbs_v1.in_python_mode() and \
                                                _pbs_v1.in_site_hook():
            # readonly under a SITE hook
            raise BadAttributeValueError("resv attribute '%s' is readonly" %
                                         (name, ))
        super(_resv, self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example,
        # _attributes_hook_set[<resv object>]=['reserve_start', 'reserve_end']
        # if 'reserve_start' or 'reserve_end' has been assigned a value within
        # the hook script, or been unset.

        if _pbs_v1.in_python_mode():
            if not self._attributes_hook_set.has_key(self):
                self._attributes_hook_set[self] = {}
            # using a dictionary value as easier to search for keys
            self._attributes_hook_set[self].update({name: None})
コード例 #2
0
ファイル: _svr_types.py プロジェクト: A9-William/pbspro
    def __setattr__(self, name, value):
        if (name == "_readonly"):
            if _pbs_v1.in_python_mode() and \
                                    hasattr(self, "_readonly") and not value:
                 raise BadAttributeValueError("_readonly can only be set to True!")
        elif not _resv.attributes.has_key(name):
            raise UnsetAttributeNameError("resv attribute '%s' not found" % (name,))
        elif name in _resv.attributes_readonly and \
                                _pbs_v1.in_python_mode() and \
                                                _pbs_v1.in_site_hook():
            # readonly under a SITE hook
            raise BadAttributeValueError("resv attribute '%s' is readonly" % (name,))
        super(_resv,self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example,
        # _attributes_hook_set[<resv object>]=['reserve_start', 'reserve_end']
        # if 'reserve_start' or 'reserve_end' has been assigned a value within
        # the hook script, or been unset.

        if _pbs_v1.in_python_mode():
            if not self._attributes_hook_set.has_key(self):
                self._attributes_hook_set[self] = {}
            # using a dictionary value as easier to search for keys
            self._attributes_hook_set[self].update({name : None})
コード例 #3
0
ファイル: _base_types.py プロジェクト: altair4/pbspro
 def __setitem__(self, name, value):
     """__setitem__"""
     # pbs builtin variables are off limits except under a PBS hook
     if name in pbs_env._attributes_readonly and \
         _pbs_v1.in_python_mode() and _pbs_v1.in_site_hook() and \
                                       not getattr(self, "_generic"):
         raise BadAttributeValueError("env variable '%s' is readonly" % (name,))
     v = value
     if isinstance(value, (str,)):
         if (_pbs_v1.get_python_daemon_name() != "pbs_python") \
                                              or (sys.platform != "win32"):
             # replace \ with \\ if not used to escape special chars
             # note: no need to do this on a Windows mom 
             #       since backslash is recognized as path character
             v = replace_char_not_before(value, '\\', '\\\\',
                                        [ ',', '\'', '\"', '\\'])
     super(pbs_env,self).__setitem__(name, v)
コード例 #4
0
 def __setitem__(self, name, value):
     """__setitem__"""
     # pbs builtin variables are off limits except under a PBS hook
     if name in pbs_env._attributes_readonly and \
         _pbs_v1.in_python_mode() and _pbs_v1.in_site_hook() and \
                                       not getattr(self, "_generic"):
         raise BadAttributeValueError("env variable '%s' is readonly" % (name,))
     v = value
     if isinstance(value, (str,)):
         if (_pbs_v1.get_python_daemon_name() != "pbs_python") \
                                              or (sys.platform != "win32"):
             # replace \ with \\ if not used to escape special chars
             # note: no need to do this on a Windows mom 
             #       since backslash is recognized as path character
             v = replace_char_not_before(value, '\\', '\\\\',
                                        [ ',', '\'', '\"', '\\'])
     super(pbs_env,self).__setitem__(name, v)