From dcb4a36959ab18685ea522f89ca03074710c06e3 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 29 Jul 2019 00:03:01 +0200 Subject: [PATCH] Replaced os.environ['HOME'] with os.path.expanduser('~') (Windows compatibility) Solves #74 --- platypush/config/__init__.py | 6 +++--- platypush/platydock/__init__.py | 4 ++-- platypush/plugins/media/__init__.py | 2 +- platypush/plugins/media/webtorrent.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index be6c2abd9..4759fbb4a 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -28,7 +28,7 @@ class Config(object): - /etc/platypush/config.yaml """ _cfgfile_locations = [ - os.path.join(os.environ['HOME'], '.config', 'platypush', 'config.yaml'), + os.path.join(os.path.expanduser('~'), '.config', 'platypush', 'config.yaml'), os.path.join(os.sep, 'etc', 'platypush', 'config.yaml'), ] @@ -37,7 +37,7 @@ class Config(object): 'now': datetime.datetime.now, } - _workdir_location = os.path.join(os.environ['HOME'], '.local', 'share', 'platypush') + _workdir_location = os.path.join(os.path.expanduser('~'), '.local', 'share', 'platypush') _included_files = set() def __init__(self, cfgfile=None): @@ -69,7 +69,7 @@ class Config(object): self._config['db'] = self._config.get('main.db', { 'engine': 'sqlite:///' + os.path.join( - os.environ['HOME'], '.local', 'share', 'platypush', 'main.db') + os.path.expanduser('~'), '.local', 'share', 'platypush', 'main.db') }) logging_config = { diff --git a/platypush/platydock/__init__.py b/platypush/platydock/__init__.py index 59d2e342b..a7cac7e3b 100755 --- a/platypush/platydock/__init__.py +++ b/platypush/platydock/__init__.py @@ -23,8 +23,8 @@ from platypush.config import Config from platypush.context import register_backends, get_plugin, get_backend -workdir = os.path.join(os.environ['HOME'], '.local', 'share', - 'platypush', 'platydock') +workdir = os.path.join(os.path.expanduser('~'), '.local', 'share', + 'platypush', 'platydock') class Action(enum.Enum): build = 'build' diff --git a/platypush/plugins/media/__init__.py b/platypush/plugins/media/__init__.py index ea25e345a..91d406f7e 100644 --- a/platypush/plugins/media/__init__.py +++ b/platypush/plugins/media/__init__.py @@ -130,7 +130,7 @@ class MediaPlugin(Plugin): self.download_dir = os.path.abspath(os.path.expanduser( download_dir or player_config.get('download_dir') or - os.path.join((os.environ['HOME'] or self._env.get('HOME') or '/'), 'Downloads'))) + os.path.join((os.path.expanduser('~') or self._env.get('HOME') or '/'), 'Downloads'))) if not os.path.isdir(self.download_dir): os.makedirs(self.download_dir, exist_ok=True) diff --git a/platypush/plugins/media/webtorrent.py b/platypush/plugins/media/webtorrent.py index 561b91f38..f496644fd 100644 --- a/platypush/plugins/media/webtorrent.py +++ b/platypush/plugins/media/webtorrent.py @@ -276,7 +276,7 @@ class MediaWebtorrentPlugin(MediaPlugin): if self._media_plugin.download_dir: return self._media_plugin.download_dir else: - d = os.path.join(os.environ['HOME'], 'Downloads') + d = os.path.join(os.path.expanduser('~'), 'Downloads') os.makedirs(d, exist_ok=True) return d