Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Thaodan:tools
osc
0010-Honor-XDG_CONFIG_HOME-and-XDG_CACHE_HOME-e...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0010-Honor-XDG_CONFIG_HOME-and-XDG_CACHE_HOME-env-vars.patch of Package osc
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Daniel Mach <daniel.mach@suse.com> Date: Wed, 14 Feb 2024 14:19:59 +0100 Subject: [PATCH] Honor XDG_CONFIG_HOME and XDG_CACHE_HOME env vars (cherry picked from commit 8e7f8fd415176dbae702028045d876fb93cc23da) --- osc/conf.py | 6 ++---- osc/core.py | 3 ++- osc/oscssl.py | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osc/conf.py b/osc/conf.py index 998ebae15bfc87dc274854a0621c34b4896a7bd4..a302e7e5ab42235b50e26c2d0dbfaefaf5ba7233 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -2055,13 +2055,11 @@ def identify_conf(): # needed for compat reasons(users may have their oscrc still in ~ if 'OSC_CONFIG' in os.environ: return os.environ.get('OSC_CONFIG') + if os.path.exists(os.path.expanduser('~/.oscrc')): return '~/.oscrc' - if os.environ.get('XDG_CONFIG_HOME', '') != '': - conffile = f"{os.environ.get('XDG_CONFIG_HOME')}/osc/oscrc" - else: - conffile = '~/.config/osc/oscrc' + conffile = os.path.join(xdg.XDG_CONFIG_HOME, "osc", "oscrc") return conffile diff --git a/osc/core.py b/osc/core.py index 36ea403e63d7592b0f46562b73755f7394fcdb87..fd2b3bc84f6ed9ad1903e8a1d75a7b3a8a07a05e 100644 --- a/osc/core.py +++ b/osc/core.py @@ -53,6 +53,7 @@ from . import oscerr from . import store as osc_store from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE from .store import Store +from .util import xdg from .util.helper import decode_list, decode_it, raw_input, _html_escape @@ -4502,7 +4503,7 @@ def _edit_message_open_editor(filename, data, orig_mtime): if os.stat(filename).st_mtime != orig_mtime: # file has changed - cache_dir = os.path.expanduser("~/.cache/osc/edited-messages") + cache_dir = os.path.expanduser(os.path.join(xdg.XDG_CACHE_HOME, "osc", "edited-messages")) try: os.makedirs(cache_dir, mode=0o700) except FileExistsError: diff --git a/osc/oscssl.py b/osc/oscssl.py index b4d4f3ada38c3762d7c33942d2c0a794b34113f9..fd6a01111f039ec224c6b06d96349bf8605bd4b3 100644 --- a/osc/oscssl.py +++ b/osc/oscssl.py @@ -13,6 +13,7 @@ from cryptography.hazmat.primitives import serialization from urllib3.util.ssl_ import create_urllib3_context from . import oscerr +from .util import xdg # based on openssl's include/openssl/x509_vfy.h.in @@ -55,7 +56,7 @@ class TrustedCertStore: if not self.host: raise ValueError("Empty `host`") - self.dir_path = os.path.expanduser("~/.config/osc/trusted-certs") + self.dir_path = os.path.expanduser(os.path.join(xdg.XDG_CONFIG_HOME, "osc", "trusted-certs")) if not os.path.isdir(self.dir_path): try: os.makedirs(self.dir_path, mode=0o700) @@ -103,7 +104,7 @@ class TrustedCertStore: Temporarily trust the certificate. """ self.cert = cert - tmp_dir = os.path.expanduser("~/.config/osc") + tmp_dir = os.path.expanduser(os.path.join(xdg.XDG_CONFIG_HOME, "osc")) data = self.cert.public_bytes(serialization.Encoding.PEM) with tempfile.NamedTemporaryFile(mode="wb+", dir=tmp_dir, prefix="temp_trusted_cert_") as f: f.write(data)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor