import struct


def int_from_bytes(val):
    """Converts val to an unsinged int assuming a BE byte order"""
    try:
        return int.from_bytes(val, 'big')
    except AttributeError:
        # Older Python, so pad it and unpack
        return struct.unpack('>L', b'\x00'*(4-len(val))+val)[0]