Nir Soffer has uploaded a new change for review.

Change subject: asserts: Replace asserts with validation function
......................................................................

asserts: Replace asserts with validation function

Replace 2 asserts for number of arguments with exiting validateArgTypes
function, that raise a clear error instead of the cryptic assert.

Another assert was removed as the code already used validateArgTypes
just after it.

Change-Id: Ib18aab097352af7cd9ca292d7ebfc79e9113d2d8
Signed-off-by: Nir Soffer <[email protected]>
---
M client/vdsClient.py
1 file changed, 4 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/29302/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index 2c09b28..64de1bc 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1123,7 +1123,6 @@
         return 0, ''
 
     def getFileStats(self, args):
-        assert args
         validateArgTypes(args, [str, str])
         response = self.s.getFileStats(*args)
         if response['status']['code']:
@@ -1475,8 +1474,8 @@
         return 0, ''
 
     def do_setLogLevel(self, args):
-        level = int(args[0])
-        assert len(args) == 1
+        validateArgTypes(args, [int], requiredArgsNumber=1):
+        level = args[0]
         stats = self.s.setLogLevel(level)
         if stats['status']['code']:
             return stats['status']['code'], stats['status']['message']
@@ -1500,9 +1499,9 @@
         return 0, ''
 
     def do_setHaMaintenanceMode(self, args):
-        assert len(args) == 2
+        validateArgTypes(args, [str, utils.tobool], requiredArgsNumber=2):
         mode = args[0]
-        enabled = utils.tobool(args[1])
+        enabled = args[1]
         stats = self.s.setHaMaintenanceMode(mode, enabled)
         if stats['status']['code']:
             return stats['status']['code'], stats['status']['message']


-- 
To view, visit http://gerrit.ovirt.org/29302
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib18aab097352af7cd9ca292d7ebfc79e9113d2d8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to