| |
@@ -0,0 +1,54 @@
|
| |
+ From 4805d3f2158d94337c11c4e7970795a46bfdbe65 Mon Sep 17 00:00:00 2001
|
| |
+ From: "Ankur Sinha (Ankur Sinha Gmail)" <sanjay.ankur@gmail.com>
|
| |
+ Date: Mon, 11 Oct 2021 16:34:33 +0100
|
| |
+ Subject: [PATCH] feat: use XDG_DATA_HOME for logging file on Linux
|
| |
+
|
| |
+ On system installations, one cannot write to
|
| |
+ `/usr/lib/pythonX.Y/site-packages` unless one always runs `pyplane` as
|
| |
+ root (which is not suggested). On Linux, the `XDG_DATA_HOME` directory
|
| |
+ should be used for user-specific data files, so the logging file is best
|
| |
+ placed here.
|
| |
+
|
| |
+ As the XDG base directory specification says, if `XDG_DATA_HOME` is not
|
| |
+ defined, `$HOME/.local/share` should be used.
|
| |
+
|
| |
+ References:
|
| |
+ https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
| |
+ ---
|
| |
+ pyplane/core/Logging.py | 14 +++++++++++++-
|
| |
+ 1 file changed, 13 insertions(+), 1 deletion(-)
|
| |
+
|
| |
+ diff --git a/pyplane/core/Logging.py b/pyplane/core/Logging.py
|
| |
+ index c8a5fc8..8bc2fab 100644
|
| |
+ --- a/pyplane/core/Logging.py
|
| |
+ +++ b/pyplane/core/Logging.py
|
| |
+ @@ -23,13 +23,25 @@ Module implementing logging capabilities
|
| |
+ import time
|
| |
+ import os
|
| |
+ import sys
|
| |
+ +import platform
|
| |
+ from PyQt5 import QtCore, QtWidgets, QtGui
|
| |
+
|
| |
+ __author__ = 'Klemens Fritzsche'
|
| |
+
|
| |
+ basedir = os.path.dirname(os.path.dirname(sys.modules.get(__name__).__file__))
|
| |
+ -defaultLogFileName = os.path.join(basedir, 'config','logmessages.txt')
|
| |
+
|
| |
+ +if platform.system() == "Linux":
|
| |
+ + try:
|
| |
+ + datadir = os.environ["XDG_DATA_HOME"] + "/pyplane/"
|
| |
+ + except KeyError:
|
| |
+ + datadir = os.environ["HOME"] + "/.local/share/pyplane/"
|
| |
+ + try:
|
| |
+ + os.makedirs(datadir)
|
| |
+ + except FileExistsError:
|
| |
+ + pass
|
| |
+ + defaultLogFileName = os.path.join(datadir, 'logmessages.txt')
|
| |
+ +else:
|
| |
+ + defaultLogFileName = os.path.join(basedir, 'config','logmessages.txt')
|
| |
+
|
| |
+ class Logger(object):
|
| |
+ """
|
| |
+ --
|
| |
+ 2.33.0
|
| |
+
|
| |
Since they are extra source files, they're not in the buildroot, so we need to manually install them there for the RPM.