Example #1
0
 def parseattr(self, p):
     attrs = {"sequential": "sequential", "require-all": "require_all"}
     l = p.split('=')
     if len(l) != 2 or l[0] not in attrs:
         return False
     k, v = l
     if not verify_boolean(v):
         return False
     setattr(self, attrs[k], get_boolean(v))
     return True
Example #2
0
 def parseattr(self, p):
     attrs = {"sequential": "sequential",
              "require-all": "require_all"}
     l = p.split('=')
     if len(l) != 2 or l[0] not in attrs:
         return False
     k, v = l
     if not verify_boolean(v):
         return False
     setattr(self, attrs[k], get_boolean(v))
     return True
Example #3
0
def test_booleans():
    truthy = ['yes', 'Yes', 'True', 'true', 'TRUE',
              'YES', 'on', 'On', 'ON']
    falsy = ['no', 'false', 'off', 'OFF', 'FALSE', 'nO']
    not_truthy = ['', 'not', 'ONN', 'TRUETH', 'yess']
    for case in chain(truthy, falsy):
        assert utils.verify_boolean(case) is True
    for case in truthy:
        assert utils.is_boolean_true(case) is True
        assert utils.is_boolean_false(case) is False
        assert utils.get_boolean(case) is True
    for case in falsy:
        assert utils.is_boolean_true(case) is False
        assert utils.is_boolean_false(case) is True
        assert utils.get_boolean(case, dflt=True) is False
    for case in not_truthy:
        assert utils.verify_boolean(case) is False
        assert utils.is_boolean_true(case) is False
        assert utils.is_boolean_false(case) is False
        assert utils.get_boolean(case) is False
Example #4
0
 def do_quorum(self, context, opt):
     "usage: quorum <bool>"
     if not utils.verify_boolean(opt):
         context.fatal_error("%s: bad boolean option" % opt)
     return cib_status.set_quorum(utils.is_boolean_true(opt))
Example #5
0
 def do_quorum(self, context, opt):
     "usage: quorum <bool>"
     if not utils.verify_boolean(opt):
         context.fatal_error("%s: bad boolean option" % opt)
     return cib_status.set_quorum(utils.is_boolean_true(opt))