diff --git a/piperider_cli/__init__.py b/piperider_cli/__init__.py index 55f525f01..665c72c8b 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,9 @@ from ruamel import yaml 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') diff --git a/piperider_cli/event/__init__.py b/piperider_cli/event/__init__.py index 46ff75a5d..f76a2ef43 100644 --- a/piperider_cli/event/__init__.py +++ b/piperider_cli/event/__init__.py @@ -5,10 +5,9 @@ from rich.console import Console from ruamel import yaml +from piperider_cli import PIPERIDER_USER_HOME, PIPERIDER_USER_PROFILE from piperider_cli.event.collector import Collector -PIPERIDER_USER_HOME = os.path.expanduser('~/.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']