summaryrefslogtreecommitdiff
path: root/mydisks.py
diff options
context:
space:
mode:
Diffstat (limited to 'mydisks.py')
-rw-r--r--mydisks.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mydisks.py b/mydisks.py
index 2a8ae47..4ca21bf 100644
--- a/mydisks.py
+++ b/mydisks.py
@@ -45,9 +45,9 @@ class MyDisks():
def open_disks(self):
"""(re)open all disks"""
logging.debug("Enter open_disks()")
- for fd in self.disks:
+ for fh in self.disks:
try:
- fd.close()
+ fh.close()
except:
pass
self.disks = [ None for d in range(self.disk_count) ]
@@ -57,15 +57,19 @@ class MyDisks():
path = self.disk_paths[d]
logging.debug("Try to open disk #%2d"%d)
try:
- self.disks[d] = open(path, "r")
- self.disks_size[d] = os.lstat(path).st_size
+ fh = open(path, "rb")
+ self.disks_size[d] = os.lseek(fh.fileno(), 0, os.SEEK_END)
+ self.disks[d] = fh
logging.debug("Opened disk #%2d"%d)
except IOError as e:
logging.error("Can't open disk #%2d ('%s') : %s"%(d, path, e.strerror))
+ logging.exception(e)
self.disks_size[d] = 0
- except:
+ except Exception as e:
logging.error("Can't open disk #%2d ('%s') : unhandled exception"%(d, path))
self.disks_size[d] = 0
+ logging.exception(e)
+
logging.debug("Exit. open_disks()")