Exemple #1
0
def read_file_as_root(file_path):
    """Secure helper to read file as root."""
    try:
        out, _err = execute('cat', file_path, run_as_root=True)
        return out
    except processutils.ProcessExecutionError:
        raise exception.FileNotFound(file_path=file_path)
Exemple #2
0
def removefile(path):
    if not os.path.exists(path):
        raise exception.FileNotFound(file_path=path)
    os.unlink(path)
Exemple #3
0
def symlink(src, dest):
    if not os.path.exists(src):
        raise exception.FileNotFound(file_path=src)
    os.symlink(src, dest)
Exemple #4
0
def readfile(path):
    if not os.path.exists(path):
        raise exception.FileNotFound(file_path=path)
    with open(path, 'r') as f:
        return f.read()