The method tries to create a file and write in it contents of result XML,
if it success, returns True, else it returns False
This method was created to improve readability and modularity of the pool
wizard code.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Wizard.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lnst/Controller/Wizard.py b/lnst/Controller/Wizard.py
index b35b216..e91413d 100644
--- a/lnst/Controller/Wizard.py
+++ b/lnst/Controller/Wizard.py
@@ -226,17 +226,20 @@ class Wizard:
return
+ def _write_to_file(self, pool_dir, filename, doc):
+ """ Writes contents of XML to a file
+ @param pool_dir Path to directory where the file will be created
+ @param filename Name of the created file
+ @param doc Contents of XML file
+ @return True if file was successfuly written, False otherwise
+ """
try:
f = open(pool_dir + "/" + filename, "w")
f.write(doc.toprettyxml())
f.close()
+ return True
except:
- msg = "File '%s/%s' could not be opened or data
written\n"\
- % (pool_dir, filename)
- sys.stderr.write(msg)
- return
-
- print("File '%s' successfuly created" % filename)
+ return False
def _get_connection(self, hostname, port):
""" Connects to machine
--
2.4.3