From d7858c4a3e0ccff11d084a2b87dde845e8cd4356 Mon Sep 17 00:00:00 2001 From: Barend Scholtus Date: Sat, 18 Jul 2020 00:36:36 +0700 Subject: [PATCH 1/2] Use APPDATA and HOME locations on Windows --- CHANGELOG | 6 ++++++ pid/__init__.py | 3 +-- pid/utils.py | 23 +++++++++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dc237bd..23e9691 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ Changelog ========= +3.0.4 +----- + + - Use APPDATA and HOME locations son Windows + + 3.0.3 ----- diff --git a/pid/__init__.py b/pid/__init__.py index d9c5d4a..f59c648 100644 --- a/pid/__init__.py +++ b/pid/__init__.py @@ -17,8 +17,7 @@ else: from .posix import PidFile # NOQA - -__version__ = "3.0.3" +__version__ = "3.0.4" __all__ = [ '__version__', 'DEFAULT_PID_DIR', diff --git a/pid/utils.py b/pid/utils.py index ecacb5b..9dfbef0 100644 --- a/pid/utils.py +++ b/pid/utils.py @@ -15,16 +15,19 @@ def effective_access(*args, **kwargs): def determine_pid_directory(): if sys.platform == "win32": - return tempfile.gettempdir() - - uid = os.geteuid() if hasattr(os, "geteuid") else os.getuid() - - paths = [ - "/run/user/%s/" % uid, - "/var/run/user/%s/" % uid, - "/run/", - "/var/run/", - ] + if 'APPDATA' in os.environ: + paths = [os.environ['APPDATA']] + else: + paths = [os.path.expanduser('~\\AppData\\Roaming')] + else: + uid = os.geteuid() if hasattr(os, "geteuid") else os.getuid() # pylint: disable=no-member + + paths = [ + "/run/user/%s/" % uid, + "/var/run/user/%s/" % uid, + "/run/", + "/var/run/", + ] for path in paths: if effective_access(os.path.realpath(path), os.W_OK | os.X_OK): From 0356a1defe6612d0ffb33c62cc7c4b2d5d0253ff Mon Sep 17 00:00:00 2001 From: trbs Date: Sat, 18 Jul 2020 04:47:43 +0200 Subject: [PATCH 2/2] fix typo --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 23e9691..ca547fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ Changelog 3.0.4 ----- - - Use APPDATA and HOME locations son Windows + - Use APPDATA and HOME locations on Windows 3.0.3