Ejemplo n.º 1
0
def update_hash_dict(filehash, filename):
    """
    Opens the pickled hash dictionary, adds an entry, and dumps it back.
    """
    try:
        with open(file_path + '/hash_dict.pickle', 'r') as f:
            hash_dict = cPickle.load(f)
    except IOError as err:
        hash_dict = {}
    hash_dict.update({filename: filehash})
    with open(os.path.join(file_path, 'hash_dict.pickle'), 'w') as f:
        cPickle.dump(hash_dict, f)
Ejemplo n.º 2
0
def update_hash_dict(filehash, filename):
    """
    Opens the pickled hash dictionary, adds an entry, and dumps it back.
    """
    try:
        with open(file_path + '/hash_dict.pickle', 'rb') as f:
            hash_dict = cPickle.load(f)
    except IOError:
        hash_dict = {}
    hash_dict.update({filename: filehash})
    with open(os.path.join(file_path, 'hash_dict.pickle'), 'wb') as f:
        cPickle.dump(hash_dict, f)
Ejemplo n.º 3
0
def check_hash(rawfile, filename):
    """
    Returns True if hash does not match the previous one.
    """
    try:
        with open(file_path + '/hash_dict.pickle', 'r') as f:
            hash_dict = cPickle.load(f)
    except IOError as err:
        hash_dict = {}
    try:
        checkhash = hash_dict[filename]
    except:
        checkhash = None

    filehash = get_hash(rawfile)
    if filehash == checkhash:
        return False, None
    return True, filehash
Ejemplo n.º 4
0
def check_hash(rawfile, filename):
    """
    Returns True if hash does not match the previous one.
    """
    try:
        with open(file_path + '/hash_dict.pickle', 'rb') as f:
            hash_dict = cPickle.load(f)
    except IOError:
        hash_dict = {}
    try:
        checkhash = hash_dict[filename]
    except:
        checkhash = None

    filehash = get_hash(rawfile)
    if filehash == checkhash:
        return False, None
    return True, filehash