diff options
Diffstat (limited to 'raidguessfs.py')
-rwxr-xr-x | raidguessfs.py | 34 |
1 files changed, 18 insertions, 16 deletions
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): |