(adir)
| 938 | |
| 939 | |
| 940 | def delete_directory_reliably(adir): |
| 941 | assert len(adir) > 2 |
| 942 | assert os.path.isdir(adir) |
| 943 | print("[build.py] Delete directory: {dir}" |
| 944 | .format(dir=adir.replace(ROOT_DIR, ""))) |
| 945 | if WINDOWS: |
| 946 | # rmtree is vulnerable to race conditions. Sometimes |
| 947 | # deleting directory fails with error: |
| 948 | # >> OSError: [WinError 145] The directory is not empty: |
| 949 | # >> 'C:\\github\\cefpython\\build\\cefpython3_56.2_win64\\build\\ |
| 950 | # >> lib\\cefpython3' |
| 951 | shutil.rmtree(adir, ignore_errors=True) |
| 952 | else: |
| 953 | # On Linux sudo might be required to delete directory, as this |
| 954 | # might be a setup installer directory with package installed |
| 955 | # using sudo and in such case files were created with sudo. |
| 956 | command = "rm -rf {dir}".format(dir=adir) |
| 957 | command = sudo_command(command, python=sys.executable) |
| 958 | os.system(command) |
| 959 | |
| 960 | |
| 961 | if __name__ == "__main__": |
no test coverage detected