Пример #1
0
def check_str_and_die(the_str, var_name, caller_name):
    """Check string for troublesome values. If bad, log and stop process."""
    try:
        check_str(the_str)
    except ValueError as err:
        logger.log_and_die("Cannot cast value '%s' to a string in %s: %s" %
                           (var_name, caller_name, str(err)))
Пример #2
0
def check_float_and_die(the_float, var_name, caller_name):
    """Check float for troublesome values. If bad, log and stop process."""
    try:
        check_float(the_float)
    except ValueError as err:
        logger.log_and_die('Exceptional value for %s in %s: %s' %
                           (var_name, caller_name, str(err)))
Пример #3
0
def check_str_and_die(the_str, var_name, caller_name):
    """Check string for troublesome values. If bad, log and stop process."""
    try:
        check_str(the_str)
    except ValueError as err:
        logger.log_and_die("Cannot cast value '%s' to a string in %s: %s" %
                           (var_name, caller_name, str(err)))
Пример #4
0
def check_float_and_die(the_float, var_name, caller_name):
    """Check float for troublesome values. If bad, log and stop process."""
    try:
        check_float(the_float)
    except ValueError as err:
        logger.log_and_die('Exceptional value for %s in %s: %s' %
                           (var_name, caller_name, str(err)))
Пример #5
0
def check_address_and_die(btc_address, caller_name):
    """If string isn't a plausible Bitcoin address, write log & stop process."""
    if not looks_like_address(btc_address):
        logger.log_and_die("Exceptional value '%s' for address in %s" %
                           (btc_address, caller_name))
Пример #6
0
def check_hex_and_die(hex_str, caller_name):
    """If string isn't a plausible hex string, write log and stop process."""
    if not looks_like_hex(hex_str):
        logger.log_and_die("Exceptional value '%s' for hex string in %s" %
                           (str(hex_str), caller_name))
Пример #7
0
def check_address_and_die(btc_address, caller_name):
    """If string isn't a plausible Bitcoin address, write log & stop process."""
    if not looks_like_address(btc_address):
        logger.log_and_die("Exceptional value '%s' for address in %s" %
                           (btc_address, caller_name))
Пример #8
0
def check_hex_and_die(hex_str, caller_name):
    """If string isn't a plausible hex string, write log and stop process."""
    if not looks_like_hex(hex_str):
        logger.log_and_die("Exceptional value '%s' for hex string in %s" %
                           (str(hex_str), caller_name))