diff --git a/piperider_cli/__init__.py b/piperider_cli/__init__.py index 55f525f01..52910eda7 100644 --- a/piperider_cli/__init__.py +++ b/piperider_cli/__init__.py @@ -3,6 +3,7 @@ import os import re import sys +import tempfile import webbrowser from datetime import datetime @@ -11,6 +12,8 @@ from ruamel import yaml PIPERIDER_USER_HOME = os.path.expanduser('~/.piperider') +if os.access(os.path.expanduser('~/'), os.W_OK) is False: + PIPERIDER_USER_HOME = os.path.join(tempfile.gettempdir(), '.piperider') PIPERIDER_USER_PROFILE = os.path.join(PIPERIDER_USER_HOME, 'profile.yml') diff --git a/piperider_cli/event/__init__.py b/piperider_cli/event/__init__.py index 46ff75a5d..39a43c959 100644 --- a/piperider_cli/event/__init__.py +++ b/piperider_cli/event/__init__.py @@ -1,4 +1,5 @@ import os +import tempfile import uuid from typing import Union @@ -8,6 +9,9 @@ from piperider_cli.event.collector import Collector PIPERIDER_USER_HOME = os.path.expanduser('~/.piperider') +if os.access(os.path.expanduser('~/'), os.W_OK) is False: + # If we can't create file in user home directory, fallback to use temp folder + PIPERIDER_USER_HOME = os.path.join(tempfile.gettempdir(), '.piperider') PIPERIDER_USER_PROFILE = os.path.join(PIPERIDER_USER_HOME, 'profile.yml') PIPERIDER_USER_EVENT_PATH = os.path.join(PIPERIDER_USER_HOME, '.unsend_events.json') PIPERIDER_FLUSH_EVENTS_WHITELIST = ['init', 'run', 'generate-report', 'compare-reports']