From a260fd8058d757b631dd4eb39ee8a58b91cf2efb Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Nov 29 2016 13:50:51 +0000 Subject: ipaclient: remove hard dependency on ipaplatform Hard-code the user cache directory path in ipaclient.remote_plugins.schema. https://fedorahosted.org/freeipa/ticket/6474 Reviewed-By: Stanislav Laznicka --- diff --git a/ipaclient/remote_plugins/__init__.py b/ipaclient/remote_plugins/__init__.py index b783c32..9cf501f 100644 --- a/ipaclient/remote_plugins/__init__.py +++ b/ipaclient/remote_plugins/__init__.py @@ -12,7 +12,6 @@ import time from . import compat from . import schema from ipaclient.plugins.rpcclient import rpcclient -from ipaplatform.paths import paths from ipapython.dnsutil import DNSName from ipapython.ipa_log_manager import log_mgr @@ -20,7 +19,7 @@ logger = log_mgr.get_logger(__name__) class ServerInfo(collections.MutableMapping): - _DIR = os.path.join(paths.USER_CACHE_PATH, 'ipa', 'servers') + _DIR = os.path.join(schema.USER_CACHE_PATH, 'ipa', 'servers') def __init__(self, api): hostname = DNSName(api.env.server).ToASCII() diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py index 5634fd1..02364ca 100644 --- a/ipaclient/remote_plugins/schema.py +++ b/ipaclient/remote_plugins/schema.py @@ -20,7 +20,6 @@ from ipalib.errors import SchemaUpToDate from ipalib.frontend import Object from ipalib.output import Output from ipalib.parameters import DefaultFrom, Flag, Password, Str -from ipaplatform.paths import paths from ipapython.ipautil import fsdecode from ipapython.dn import DN from ipapython.dnsutil import DNSName @@ -31,6 +30,17 @@ FORMAT = '1' if six.PY3: unicode = str +USER_CACHE_PATH = ( + os.environ.get('XDG_CACHE_HOME') or + os.path.join( + os.environ.get( + 'HOME', + os.path.expanduser('~') + ), + '.cache' + ) +) + _TYPES = { 'DN': DN, 'DNSName': DNSName, @@ -357,7 +367,7 @@ class Schema(object): """ namespaces = {'classes', 'commands', 'topics'} - _DIR = os.path.join(paths.USER_CACHE_PATH, 'ipa', 'schema', FORMAT) + _DIR = os.path.join(USER_CACHE_PATH, 'ipa', 'schema', FORMAT) def __init__(self, client, fingerprint=None): self._dict = {} diff --git a/ipaplatform/base/paths.py b/ipaplatform/base/paths.py index ac22f3e..9942fc1 100644 --- a/ipaplatform/base/paths.py +++ b/ipaplatform/base/paths.py @@ -21,8 +21,6 @@ This base platform module exports default filesystem paths. ''' -import os - class BasePathNamespace(object): BASH = "/bin/bash" @@ -350,17 +348,4 @@ class BasePathNamespace(object): IPA_GETKEYTAB = '/usr/sbin/ipa-getkeytab' EXTERNAL_SCHEMA_DIR = '/usr/share/ipa/schema.d' - @property - def USER_CACHE_PATH(self): - return ( - os.environ.get('XDG_CACHE_HOME') or - os.path.join( - os.environ.get( - 'HOME', - os.path.expanduser('~') - ), - '.cache' - ) - ) - path_namespace = BasePathNamespace