Mahmudm commited on
Commit
c4d34aa
·
verified ·
1 Parent(s): d12a381

Update ash_animator/basemaps.py

Browse files
Files changed (1) hide show
  1. ash_animator/basemaps.py +11 -4
ash_animator/basemaps.py CHANGED
@@ -5,8 +5,12 @@ import contextily as ctx
5
  from mpl_toolkits.basemap import Basemap
6
 
7
 
 
 
 
8
  def get_cache_dir(app_name):
9
- return os.path.join(os.getcwd(), f"{app_name}_cache")
 
10
 
11
  # Define and create cache directories
12
  CTX_TILE_CACHE_DIR = get_cache_dir("contextily")
@@ -17,9 +21,12 @@ os.environ["XDG_CACHE_HOME"] = CTX_TILE_CACHE_DIR
17
  os.environ["CARTOPY_USER_BACKGROUNDS"] = CARTOPY_CACHE_DIR
18
  os.environ["CARTOPY_CACHE_DIR"] = CARTOPY_CACHE_DIR
19
 
20
- os.makedirs(CTX_TILE_CACHE_DIR, exist_ok=True)
21
- os.makedirs(BASEMAP_TILE_CACHE_DIR, exist_ok=True)
22
- os.makedirs(CARTOPY_CACHE_DIR, exist_ok=True)
 
 
 
23
 
24
 
25
  import cartopy.crs as ccrs
 
5
  from mpl_toolkits.basemap import Basemap
6
 
7
 
8
+ import os
9
+ import tempfile
10
+
11
  def get_cache_dir(app_name):
12
+ return os.path.join(tempfile.gettempdir(), f"{app_name}_cache")
13
+
14
 
15
  # Define and create cache directories
16
  CTX_TILE_CACHE_DIR = get_cache_dir("contextily")
 
21
  os.environ["CARTOPY_USER_BACKGROUNDS"] = CARTOPY_CACHE_DIR
22
  os.environ["CARTOPY_CACHE_DIR"] = CARTOPY_CACHE_DIR
23
 
24
+ if not os.path.exists(CTX_TILE_CACHE_DIR):
25
+ os.makedirs(CTX_TILE_CACHE_DIR, exist_ok=True)
26
+ if not os.path.exists(BASEMAP_TILE_CACHE_DIR):
27
+ os.makedirs(BASEMAP_TILE_CACHE_DIR, exist_ok=True)
28
+ if not os.path.exists(CARTOPY_CACHE_DIR):
29
+ os.makedirs(CARTOPY_CACHE_DIR, exist_ok=True)
30
 
31
 
32
  import cartopy.crs as ccrs