def get_counter(counterfile):
    """Get the counter value"""
    try:
        version_num = open(counterfile).read()
        version_num = int(version_num) + 1
    except (ValueError, IOError):
        version_num = 1
        create_file(counterfile, "%d" % version_num)
    except BaseException as msg:
        raise SaChannelUpdateError(msg)
    return version_num
Get the counter value