MCPcopy Create free account
hub / github.com/cztomczak/cefpython / delete_directory_reliably

Function delete_directory_reliably

tools/build.py:940–958  ·  view source on GitHub ↗
(adir)

Source from the content-addressed store, hash-verified

938
939
940def 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
961if __name__ == "__main__":

Callers 1

install_and_runFunction · 0.85

Calls 1

sudo_commandFunction · 0.85

Tested by

no test coverage detected