Exemple #1
0
    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})
Exemple #2
0
    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 ((name != "_rerun") and (name != "_delete") and \
              (name != "_checkpointed") and (name != "_msmom") and \
              (name != "_stdout_file") and (name != "_stderr_file") and \
                                 not _job.attributes.has_key(name)):
            raise UnsetAttributeNameError("job attribute '%s' not found" %
                                          (name, ))

        super(_job, self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example,
        # _attributes_hook_set[<job object>]=['Priority', 'comment']
        # if 'comment' or 'Priority' 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})
Exemple #3
0
    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 ((name != "_rerun") and (name != "_delete") and \
              (name != "_checkpointed") and (name != "_msmom") and \
              (name != "_stdout_file") and (name != "_stderr_file") and \
                                 not _job.attributes.has_key(name)):
            raise UnsetAttributeNameError("job attribute '%s' not found" % (name,))

        super(_job,self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example,
        # _attributes_hook_set[<job object>]=['Priority', 'comment']
        # if 'comment' or 'Priority' 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})
Exemple #4
0
    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})
Exemple #5
0
 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 _pbs_v1.in_python_mode() and self._param.__contains__(name):
         if name == "progname" or name == "argv" or name == "env":
             self._param[name] = value
             return
         else:
             raise BadAttributeValueError("event attribute '%s' is readonly" % (name,))
     elif not _event.attributes.has_key(name):
         raise UnsetAttributeNameError("event attribute '%s' not found" % (name,))
     super(_event,self).__setattr__(name, value)
Exemple #6
0
 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 _pbs_v1.in_python_mode() and self._param.__contains__(name):
         if name == "progname" or name == "argv" or name == "env":
             self._param[name] = value
             return
         else:
             raise BadAttributeValueError("event attribute '%s' is readonly" % (name,))
     elif not _event.attributes.has_key(name):
         raise UnsetAttributeNameError("event attribute '%s' not found" % (name,))
     super(_event,self).__setattr__(name, value)
Exemple #7
0
    def __set__(self, obj, value):
        """__set___
        """

        if not _IS_SETTABLE(self, obj, value):
            return

	# if in Python (hook script mode), the hook writer has set value to
 	# to None, meaning to unset the attribute.
        if (value is None) and _pbs_v1.in_python_mode():
            set_value = ""
        elif (value is None) or (value == "") \
             or isinstance(value, self._value_type) \
             or self._is_entity \
             or (hasattr(obj, "_is_entity") \
                    and getattr(obj, "_is_entity")):

            # no instantiation/transformation of value needed if matching
            # one of the following cases:
            #     - value is unset  : (value is None) or (value == "")
            #     - same type as value's type :
            #                       (isinstance(value, self._value_type)
            #     - a special entity resource type : self.is_entity is True
            #                             or parent object is an entity type
            set_value = value
        else:
            if self._is_resource and isinstance(value, str) and (value[0] == "@"):
                # an indirect resource
                set_value = value
            else:
                set_value = self._value_type[0](value)
        #:
        self.__per_instance[obj] = set_value
Exemple #8
0
    def __set__(self, obj, value):
        """__set___
        """

        if not _IS_SETTABLE(self, obj, value):
            return

	# if in Python (hook script mode), the hook writer has set value to
 	# to None, meaning to unset the attribute.
        if (value is None) and _pbs_v1.in_python_mode():
            set_value = ""
        elif (value is None) or (value == "") \
             or isinstance(value, self._value_type) \
             or self._is_entity \
             or (hasattr(obj, "_is_entity") \
                    and getattr(obj, "_is_entity")):

            # no instantiation/transformation of value needed if matching
            # one of the following cases:
            #     - value is unset  : (value is None) or (value == "")
            #     - same type as value's type :
            #                       (isinstance(value, self._value_type)
            #     - a special entity resource type : self.is_entity is True
            #                             or parent object is an entity type
            set_value = value
        else:
            if self._is_resource and isinstance(value, str) and (value[0] == "@"):
                # an indirect resource
                set_value = value
            else:
                set_value = self._value_type[0](value)
        #:
        self.__per_instance[obj] = set_value
Exemple #9
0
 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 _server.attributes.has_key(name):
         raise UnsetAttributeNameError("server attribute '%s' not found" % (name,))
     super(_server,self).__setattr__(name, value)
Exemple #10
0
 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 _server.attributes.has_key(name):
         raise UnsetAttributeNameError("server attribute '%s' not found" % (name,))
     super(_server,self).__setattr__(name, value)
Exemple #11
0
    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 _vnode.attributes.has_key(name):
            raise UnsetAttributeNameError("vnode attribute '%s' not found" % (name,))
        super(_vnode,self).__setattr__(name, value)

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

        if _pbs_v1.in_python_mode() and (name != "_connect_server"):
            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})
            _pbs_v1.mark_vnode_set(self.name, name, str(value))        
Exemple #12
0
    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 _vnode.attributes.has_key(name):
            raise UnsetAttributeNameError("vnode attribute '%s' not found" % (name,))
        super(_vnode,self).__setattr__(name, value)

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

        if _pbs_v1.in_python_mode() and (name != "_connect_server"):
            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})
            _pbs_v1.mark_vnode_set(self.name, name, str(value))        
Exemple #13
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)
Exemple #14
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)
Exemple #15
0
    def __setattr__(self, nameo, value):
        """__setattr__"""

        name = nameo
        if (nameo == "_readonly"):
            if _pbs_v1.in_python_mode() and \
                    hasattr(self, "_readonly") and not value:
                raise BadResourceValueError("_readonly can only be set to True!")
        elif (nameo != "_has_value") and (nameo != "_is_entity"):
            # _has_value is a special, resource attribute that tells if a
            # resource instance is already holding its value (i.e. value
            # is not cached somewhere else).
            # _is_entity is also a special attribute that tells if the
            # resource instance is an entity resource type. 

            # resource names in PBS are case insensitive,
            # so do caseless matching here.
            found = False
            namel = nameo.lower()
            for resc in pbs_resource.attributes:
                rescl = resc.lower()
                if namel == rescl:
                   # Need to use the matched name stored in PBS Python resource
	           # table, to avoid resource ambiguity later on.
                   name = resc
                   found = True

            if not found:

                if _pbs_v1.in_python_mode():
                    # if attribute name not found,and executing inside Python script
                    if _pbs_v1.get_python_daemon_name() != "pbs_python":
                        # we're in a server hook  
                        raise UnsetResourceNameError("resource attribute '%s' not found" % (name,)) 

                    # we're in a mom hook, so no longer raising an exception here since if
                    # it's an unknown resource, we can now tell server to
                    # automatically add a custom resource.
                    if not self._attributes_unknown.has_key(self):
                        self._attributes_unknown[self] = {}
                    # add the current attribute name to the "unknown" list
                    self._attributes_unknown[self].update({name : None})
                else:
                    if not self._attributes_unknown.has_key(self):
                        self._attributes_unknown[self] = {}
                    # add the current attribute name to the "unknown" list
                    self._attributes_unknown[self].update({name : None})

        super(pbs_resource,self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example, 
        # _attributes_hook_set[<pbs_resource object>]=['walltime', 'mem']
        # if 'walltime' or 'mem' 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})
Exemple #16
0
 def __init__(self,value):
     # Validate only if set inside a hook script and not internally
     # by PBS.
     if _pbs_v1.in_python_mode():
         _pbs_v1.validate_input("job", "project", value)
     super(project,self).__init__(value)
Exemple #17
0
    def __setattr__(self, nameo, value):
        """__setattr__"""

        name = nameo
        if (nameo == "_readonly"):
            if _pbs_v1.in_python_mode() and \
                    hasattr(self, "_readonly") and not value:
                raise BadResourceValueError("_readonly can only be set to True!")
        elif (nameo != "_has_value") and (nameo != "_is_entity"):
            # _has_value is a special, resource attribute that tells if a
            # resource instance is already holding its value (i.e. value
            # is not cached somewhere else).
            # _is_entity is also a special attribute that tells if the
            # resource instance is an entity resource type. 

            # resource names in PBS are case insensitive,
            # so do caseless matching here.
            found = False
            namel = nameo.lower()
            for resc in pbs_resource.attributes:
                rescl = resc.lower()
                if namel == rescl:
                   # Need to use the matched name stored in PBS Python resource
	           # table, to avoid resource ambiguity later on.
                   name = resc
                   found = True

            if not found:

                if _pbs_v1.in_python_mode():
                    # if attribute name not found,and executing inside Python script
                    if _pbs_v1.get_python_daemon_name() != "pbs_python":
                        # we're in a server hook  
                        raise UnsetResourceNameError("resource attribute '%s' not found" % (name,)) 

                    # we're in a mom hook, so no longer raising an exception here since if
                    # it's an unknown resource, we can now tell server to
                    # automatically add a custom resource.
                    if not self._attributes_unknown.has_key(self):
                        self._attributes_unknown[self] = {}
                    # add the current attribute name to the "unknown" list
                    self._attributes_unknown[self].update({name : None})
                else:
                    if not self._attributes_unknown.has_key(self):
                        self._attributes_unknown[self] = {}
                    # add the current attribute name to the "unknown" list
                    self._attributes_unknown[self].update({name : None})

        super(pbs_resource,self).__setattr__(name, value)

        # attributes that are set in python mode will be reflected in
        # _attributes_hook_set dictionary.
        # For example, 
        # _attributes_hook_set[<pbs_resource object>]=['walltime', 'mem']
        # if 'walltime' or 'mem' 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})
Exemple #18
0
 def __init__(self,value):
     # Validate only if set inside a hook script and not internally
     # by PBS.
     if _pbs_v1.in_python_mode():
         _pbs_v1.validate_input("job", "project", value)
     super(project,self).__init__(value)