コード例 #1
0
    def xml_write(self, hardware_object_name, path, value):
        if self.server.hardwareRepositoryDirectory is not None:
            filename = os.path.normpath(
                self.server.hardwareRepositoryDirectory + hardware_object_name + ".xml"
            )

            if os.path.exists(filename):
                try:
                    return SimpleXMLReadWriteSupport.update(
                        filename, path, value, filename
                    )
                except SAXParseException as msg:
                    return {
                        "__error__": "Could not parse hardware object file %s : %s"
                        % (hardware_object_name, msg)
                    }
                except Exception:
                    return {
                        "__error__": "Could not update hardware object %s"
                        % hardware_object_name
                    }
                else:
                    self.server.broadcast_update_event(hardware_object_name)
            else:
                return {"__error__": "%s does not exist." % hardware_object_name}
        else:
            return {"__error__": "No server."}
コード例 #2
0
    def xml_write(self, hardwareObjectName, path, value):
        if self.server.hardwareRepositoryDirectory is not None:
            filename = os.path.normpath(
                self.server.hardwareRepositoryDirectory + hardwareObjectName +
                '.xml')

            if os.path.exists(filename):
                try:
                    return SimpleXMLReadWriteSupport.update(
                        filename, path, value, filename)
                except SAXParseException as msg:
                    return {
                        '__error__':
                        'Could not parse hardware object file %s : %s' %
                        (hardwareObjectName, msg)
                    }
                except:
                    return {
                        '__error__':
                        'Could not update hardware object %s' %
                        hardwareObjectName
                    }
                else:
                    self.server.broadcast_update_event(hardwareObjectName)
            else:
                return {'__error__': '%s does not exist.' % hardwareObjectName}
        else:
            return {'__error__': 'No server.'}
コード例 #3
0
    def xml_write(self, hardwareObjectName, path, value):
        if self.server.hardwareRepositoryDirectory is not None:
            filename = os.path.normpath(
                self.server.hardwareRepositoryDirectory + hardwareObjectName + ".xml"
            )

            if os.path.exists(filename):
                try:
                    return SimpleXMLReadWriteSupport.update(
                        filename, path, value, filename
                    )
                except SAXParseException as msg:
                    return {
                        "__error__": "Could not parse hardware object file %s : %s"
                        % (hardwareObjectName, msg)
                    }
                except BaseException:
                    return {
                        "__error__": "Could not update hardware object %s"
                        % hardwareObjectName
                    }
                else:
                    self.server.broadcast_update_event(hardwareObjectName)
            else:
                return {"__error__": "%s does not exist." % hardwareObjectName}
        else:
            return {"__error__": "No server."}
コード例 #4
0
 def xml_write(self, hardwareObjectName, path, value):
    if self.server.hardwareRepositoryDirectory is not None:
        filename = os.path.normpath(self.server.hardwareRepositoryDirectory + hardwareObjectName + '.xml')
        
        if os.path.exists(filename):
            try:
                 return SimpleXMLReadWriteSupport.update(filename, path, value, filename)
            except SAXParseException, msg:
                 return { '__error__': 'Could not parse hardware object file %s : %s' % (hardwareObjectName, msg) }
            except: