summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway.scripts
diff options
context:
space:
mode:
authorBala.FA <bala@gluster.com>2011-09-20 15:06:45 +0530
committerTim <timothyasir@gluster.com>2011-09-23 13:58:01 +0530
commiteb94bb5dc369b1c57bbc12c76707db2e620d41f1 (patch)
tree7f1b3a49b1dc735669a2c06c2d301231c32a2e28 /src/com.gluster.storage.management.gateway.scripts
parentdd70b4940f0a99004d74b5b4b7b66a3ed4c95a39 (diff)
Added writeFile() function in Utils.py
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src/com.gluster.storage.management.gateway.scripts')
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py
index 874acaa8..9423c0af 100644
--- a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py
@@ -722,3 +722,17 @@ def readFile(fileName, lines=False):
return []
else:
return ""
+
+
+def writeFile(fileName, content):
+ try:
+ fp = open(fileName, "w")
+ if isString(content):
+ fp.write(content)
+ elif type(content) == type([]):
+ fp.writelines(content)
+ fp.close()
+ return True
+ except IOError, e:
+ log("failed to write file %s: %s" % (fileName, str(e))
+ return False