summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <lpouzenc@gmail.com>2015-07-12 11:34:29 +0200
committerLudovic Pouzenc <lpouzenc@gmail.com>2015-07-12 11:34:29 +0200
commitef6f38ff041287a2c198e53ab4f0213914979ce9 (patch)
treeebf659b9fa5eacac2b186c79616d7516d2024d5d
parentc0a498de02cebaa9bd462d611599f0be6809357e (diff)
downloadraidguessfs-ef6f38ff041287a2c198e53ab4f0213914979ce9.tar.gz
raidguessfs-ef6f38ff041287a2c198e53ab4f0213914979ce9.tar.bz2
raidguessfs-ef6f38ff041287a2c198e53ab4f0213914979ce9.zip
Comments and error handling
-rw-r--r--mydisks.py2
-rwxr-xr-xraidguessfs.py34
2 files changed, 19 insertions, 17 deletions
diff --git a/mydisks.py b/mydisks.py
index b249198..2a8ae47 100644
--- a/mydisks.py
+++ b/mydisks.py
@@ -34,7 +34,7 @@ class MyDisks():
return self.disk_count
def set_disks_path(self,disk_path_list):
- """Set the list of real filepath to disks or images and (re)open them"""
+ """Set the list of real filepath to disks or images"""
self.disk_paths = disk_path_list
def set_disk_count(self,new_disk_count):
diff --git a/raidguessfs.py b/raidguessfs.py
index 84440c9..e76d1f3 100755
--- a/raidguessfs.py
+++ b/raidguessfs.py
@@ -48,7 +48,7 @@ class RaidGuessFS(fuse.Fuse):
logging.debug("Enter RaidGuessFS.__init__()")
super(RaidGuessFS,self).__init__(*args, **kwargs)
- # Early initialisations (notably the static directory tree part)
+ # Early initialisations (notably modules and the static directory tree part)
self.d = mydisks.MyDisks()
self.raid = myraid.MyRaid()
self.bmp = mybinview.MyBinView()
@@ -140,10 +140,18 @@ class RaidGuessFS(fuse.Fuse):
else:
return []
- def update_disk_count(self,arg):
+ def _aton(self,arg,allow_zero=True):
i = int(arg)
- #TODO : raise exception instead of using assertions
- assert (i > 0), "Negative value make no sense here"
+ if allow_zero:
+ if i < 0:
+ raise ValueError("Negative value make no sense here")
+ else:
+ if i <= 0:
+ raise ValueError("Non-positive value make no sense here")
+ return i
+
+ def update_disk_count(self,arg):
+ i = self._aton(arg)
self.d.set_disk_count(i)
self.d.open_disks()
self._refresh_disk_dentries()
@@ -152,41 +160,35 @@ class RaidGuessFS(fuse.Fuse):
self.update_raid_disk_order(range(i))
def update_bmp_start_offset(self, arg):
- i = int(arg)
- assert (i >= 0), "Negative value make no sense here"
+ i = self._aton(arg)
self.bmp.set_bmp_start_offset(i)
self.bmp.refresh_bmp()
self._refresh_disk_dentries()
def update_bmp_width(self, arg):
- i = int(arg)
- assert (i > 0), "Non-positive value make no sense here"
+ i = self._aton(arg,False)
self.bmp.set_bmp_width(i)
self.bmp.refresh_bmp()
self._refresh_disk_dentries()
def update_bmp_height(self, arg):
- i = int(arg)
- assert (i > 0), "Non-positive value make no sense here"
+ i = self._aton(arg,False)
self.bmp.set_bmp_height(i)
self.bmp.refresh_bmp()
self._refresh_disk_dentries()
def update_raid_start(self, arg):
- i = int(arg)
- assert (i >= 0), "Negative value make no sense here"
+ i = self._aton(arg)
self.raid.set_raid_start(i)
self._refresh_raid_fattr()
def update_raid_end(self, arg):
- i = int(arg)
- assert (i >= 0), "Negative value make no sense here"
+ i = self._aton(arg)
self.raid.set_raid_end(i)
self._refresh_raid_fattr()
def update_raid_chunk_size(self, arg):
- i = int(arg)
- assert (i > 0), "Non-positive value make no sense here"
+ i = self._aton(arg,False)
self.raid.set_raid_chunk_size(i)
def update_raid_disk_order(self, arg):