Example #1
0
def restore_as_sudo_subprocess(backup_location, sudo_password, move=False):
    backup_loc_path = os.path.abspath(os.path.expanduser(backup_location))
    if move:
        args = [sys.executable, __file__, "-m", "restore", backup_loc_path]
    else:
        args = [sys.executable, __file__, "restore", backup_loc_path]
    process.run_sudo_program(args, sudo_password, logger)
Example #2
0
def save_as_sudo_subprocess(file_list, backup_location, sudo_password, move=False):
    backup_loc_path = os.path.abspath(os.path.expanduser(backup_location))
    f = tempfile.NamedTemporaryFile(delete=False)
    try:
        f.write("\n".join(file_list))
        f.close()
        if move:
            args = [sys.executable, __file__, "-f", f.name, "-m", "save", backup_loc_path]
        else:
            args = [sys.executable, __file__, "-f", f.name, "save", backup_loc_path]
        process.run_sudo_program(args, sudo_password, logger)
    finally:
        os.unlink(f.name)