Skip to content

Commit

Permalink
Windows skip check
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Sep 9, 2021
1 parent 8ea78fb commit a3baf75
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ def get_latest_run(search_dir='.'):

def user_config_dir(dir='Ultralytics'):
# Return path of user configuration directory (make if necessary)
system = platform.system()
cfg = {'Windows': 'AppData/Roaming', 'Linux': '.config', 'Darwin': 'Library/Application Support'}
path = Path.home() / cfg.get(platform.system(), '') / dir
if not is_writeable(path): # GCP functions and AWS lambda solution, only /tmp is writeable
path = Path.home() / cfg.get(system, '') / dir
if system == 'Linux' and not is_writeable(path): # GCP functions and AWS lambda solution, only /tmp is writeable
path = Path('/tmp') / dir
if not path.is_dir():
path.mkdir() # make dir if required
return path


def is_writeable(path):
# Return True if path has write permissions
# Return True if path has write permissions (Warning: known issue on Windows)
return os.access(path, os.R_OK)


Expand Down

0 comments on commit a3baf75

Please sign in to comment.