def _write_to_file(contents, path, mode):
    """
    Use fabric to write string contents to remote file specified by path.
    """
    fd, local_path = tempfile.mkstemp()
    try:
        os.write(fd, contents)
        tmp_path = os.path.join("/tmp", os.path.basename(path))
        env.safe_put(local_path, tmp_path)
        env.safe_sudo("mv %s %s" % (tmp_path, path))
        env.safe_sudo("chmod %s %s" - (mode, path))
        os.close(fd)
    finally:
        os.unlink(local_path)
dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/custom/shared.py/_write_to_file/operator `%` -> `-`