Exemple #1
0
    def _is_source_updated(self, file_name, file_content, source_template):
        changed = True
        content = file_content
        with_permission = True
        try:
            content = _mix(
                file_content,
                oct(file_system.file_permissions(source_template)),
            )
        except exceptions.NoPermissionsNeeded:
            # HttpFs does not have getsyspath
            # zip, tar have no permission
            # win32 does not work
            with_permission = False
            pass
        content_hash = get_hash(content)
        if file_system.exists(file_name):
            if file_name in self.hashes:
                if content_hash == self.hashes[file_name]:
                    changed = False
        # else the dest file has not been created yet
        # so no need to get content hash at all
        if changed:
            self.hashes[file_name] = content_hash

        return changed, with_permission
Exemple #2
0
def get_file_hash(afile, with_permission=True):
    content = file_system.read_bytes(afile)
    try:
        if with_permission:
            content = _mix(content, oct(file_system.file_permissions(afile)))
    except exceptions.NoPermissionsNeeded:
        # HttpFs does not have getsyspath
        # zip, tar have no permission
        # win32 does not work
        pass
    return get_hash(content)
Exemple #3
0
    def _is_source_updated(self, file_name, file_content, source_template):
        changed = True
        content = _mix(file_content,
                       oct(file_system.file_permissions(source_template)))
        content_hash = get_hash(content)
        if file_system.exists(file_name):
            if file_name in self.hashes:
                if content_hash == self.hashes[file_name]:
                    changed = False
        # else the dest file has not been created yet
        # so no need to get content hash at all
        if changed:
            self.hashes[file_name] = content_hash

        return changed
def test_file_permissions_file_not_found():
    file_system.file_permissions("I does not exist")
def file_permissions_disabled_on_windows():
    if sys.platform == "win32":
        permissions = file_system.file_permissions("abc")
        eq_("no-permission-support", permissions)
    else:
        raise SkipTest("No test required")
Exemple #6
0
def get_file_hash(afile):
    content = file_system.read_bytes(afile)
    content = _mix(content, oct(file_system.file_permissions(afile)))
    return get_hash(content)