Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syspaths.py warning message #52352

Merged
merged 16 commits into from
Apr 26, 2019
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions salt/syspaths.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
'''
:codeauthor: Pedro Algarvio (pedro@algarvio.me)


salt.syspaths
~~~~~~~~~~~~~

Expand All @@ -21,9 +18,17 @@
from __future__ import absolute_import, print_function, unicode_literals
import sys
import os.path
import logging

__PLATFORM = sys.platform.lower()

typo_warning = True
log = logging.getLogger(__name__)
EXPECTED_VARIABLES = ('ROOT_DIR', 'CONFIG_DIR', 'CACHE_DIR', 'SOCK_DIR',
'SRV_ROOT_DIR', 'BASE_FILE_ROOTS_DIR', 'HOME_DIR',
'BASE_PILLAR_ROOTS_DIR', 'BASE_THORIUM_ROOTS_DIR',
'BASE_MASTER_ROOTS_DIR', 'LOGS_DIR', 'PIDFILE_DIR',
'SPM_PARENT_PATH', 'SPM_FORMULA_PATH', 'SPM_PILLAR_PATH',
'SPM_REACTOR_PATH', 'SHARE_DIR')

try:
# Let's try loading the system paths from the generated module at
Expand All @@ -32,14 +37,19 @@
except ImportError:
import types
__generated_syspaths = types.ModuleType(str('salt._syspaths')) # future lint: blacklisted-function
for key in ('ROOT_DIR', 'CONFIG_DIR', 'CACHE_DIR', 'SOCK_DIR',
'SRV_ROOT_DIR', 'BASE_FILE_ROOTS_DIR', 'HOME_DIR',
'BASE_PILLAR_ROOTS_DIR', 'BASE_THORIUM_ROOTS_DIR',
'BASE_MASTER_ROOTS_DIR', 'LOGS_DIR', 'PIDFILE_DIR',
'SPM_PARENT_PATH', 'SPM_FORMULA_PATH',
'SPM_PILLAR_PATH', 'SPM_REACTOR_PATH', 'SHARE_DIR'):
for key in EXPECTED_VARIABLES:
setattr(__generated_syspaths, key, None)

else:
for key in EXPECTED_VARIABLES:
if hasattr(__generated_syspaths, key):
continue
else:
if typo_warning:
log.warning('Possible Typo?')
log.warning('To dissolve this warning add `[variable] = None` to _syspaths.py')
alan-cugler marked this conversation as resolved.
Show resolved Hide resolved
typo_warning = False
log.warning('Variable %s is missing, value set to None', key)
setattr(__generated_syspaths, key, None) # missing variables defaulted to None

# Let's find out the path of this module
if 'SETUP_DIRNAME' in globals():
Expand Down