Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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()
"""
# 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