How to use the fcp.xmlobject.XMLFile function in fcp

To help you get started, we’ve selected a few fcp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freenet / pyFreenet / freedisk.py View on Github external
def load(self):
        """
        Loads config from self.config
        """
        # get the raw xml, plain or encrypted
        ciphertext = file(self.path, "rb").read()
    
        plaintext = ciphertext
    
        # try to wrap into xml object
        try:
            xml = self.xml = XMLFile(raw=plaintext)
        except:
            i = 0
            while i < 3:
                passwd = self.passwd = getpasswd("Freedisk config password")
                plaintext = decrypt(self.passwd, ciphertext)
                try:
                    xml = XMLFile(raw=plaintext)
                    break
                except:
                    i += 1
                    continue
            if i == 3:
                self.abort()
    
        self.xml = xml
        self.root = xml.root
github freenet / pyFreenet / freedisk.py View on Github external
def create(self):
        """
        Creates a new config object
        """
        self.xml = XMLFile(root="freedisk")
        root = self.root = self.xml.root
    
        self.fcpHost = fcp.node.defaultFCPHost
        self.fcpPort = fcp.node.defaultFCPPort
        self.fcpVerbosity = fcp.node.defaultVerbosity
        self.mountpoint = defaultMountpoint
    
        self.save()
github freenet / pyFreenet / freedisk.py View on Github external
"""
        # get the raw xml, plain or encrypted
        ciphertext = file(self.path, "rb").read()
    
        plaintext = ciphertext
    
        # try to wrap into xml object
        try:
            xml = self.xml = XMLFile(raw=plaintext)
        except:
            i = 0
            while i < 3:
                passwd = self.passwd = getpasswd("Freedisk config password")
                plaintext = decrypt(self.passwd, ciphertext)
                try:
                    xml = XMLFile(raw=plaintext)
                    break
                except:
                    i += 1
                    continue
            if i == 3:
                self.abort()
    
        self.xml = xml
        self.root = xml.root