summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway.scripts/src/backend
diff options
context:
space:
mode:
authorBala.FA <bala@gluster.com>2011-09-22 11:18:16 +0530
committerTim <timothyasir@gluster.com>2011-09-23 13:58:02 +0530
commitf3402bd2508732351f7e02e333fc87f8eb2ac581 (patch)
tree052e150ff93d0f864161dc4b028ead6378d55911 /src/com.gluster.storage.management.gateway.scripts/src/backend
parenta588ec2f584d2a5a0e10055bf81cdd8212d6085f (diff)
Cleanup in get_brick_status.py
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src/com.gluster.storage.management.gateway.scripts/src/backend')
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py
index afc15f3a..b72321d7 100755
--- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py
@@ -24,22 +24,22 @@ def main():
if not os.path.exists(pidFile):
print "OFFLINE"
- else:
- try:
- fp = open(pidFile)
- pidString = fp.readline()
- fp.close()
- os.getpgid(int(pidString))
- print "ONLINE"
- except IOError, e:
- Utils.log("failed to open file %s: %s" % (pidFile, str(e)))
- print "UNKNOWN"
- except ValueError, e:
- Utils.log("invalid pid %s in file %s: %s" % (pidString, pidFile, str(e)))
- print "UNKNOWN"
- except OSError, e:
- #Utils.log("failed to get process detail of pid %s: %s" % (pidString, str(e)))
- print "OFFLINE"
+ sys.exit(0)
+
+ lines = Utils.readFile(pidFile)
+ if not lines:
+ print "UNKNOWN"
+ sys.exit(0)
+ try:
+ pidString = lines[0]
+ os.getpgid(int(pidString))
+ print "ONLINE"
+ except ValueError, e:
+ Utils.log("invalid pid %s in file %s: %s" % (pidString, pidFile, str(e)))
+ print "UNKNOWN"
+ except OSError, e:
+ #Utils.log("failed to get process detail of pid %s: %s" % (pidString, str(e)))
+ print "OFFLINE"
sys.exit(0)
if __name__ == "__main__":