From 85bd41729c8fd6249f4866844ecf9bb131e2dcfe Mon Sep 17 00:00:00 2001 From: Ted Chambers Date: Thu, 13 Aug 2020 11:30:54 -0400 Subject: [PATCH] fix for issue #354 (#356) * fix for issue #354 * catch OSError instead of FileExistsError, since FileExistsError is not available in python 2.7 --- azure-devops/azure/devops/_file_cache.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/azure-devops/azure/devops/_file_cache.py b/azure-devops/azure/devops/_file_cache.py index 55da484c..2415ebab 100644 --- a/azure-devops/azure/devops/_file_cache.py +++ b/azure-devops/azure/devops/_file_cache.py @@ -114,7 +114,13 @@ def get_cache_dir(): azure_devops_cache_dir = os.getenv('AZURE_DEVOPS_CACHE_DIR', None)\ or os.path.expanduser(os.path.join('~', '.azure-devops', 'python-sdk', 'cache')) if not os.path.exists(azure_devops_cache_dir): - os.makedirs(azure_devops_cache_dir) + try: + os.makedirs(azure_devops_cache_dir) + except OSError: + # https://github.com/microsoft/azure-devops-python-api/issues/354 + # FileExistsError is not available in python 2.7 + if not os.path.exists(azure_devops_cache_dir): + raise return azure_devops_cache_dir