Skip to content

Commit

Permalink
Merge pull request #10 from mirceaulinic/sproxy-path
Browse files Browse the repository at this point in the history
Ensure ISalt is able to handle whatever extension modules from salt-sproxy
  • Loading branch information
mirceaulinic authored Feb 18, 2021
2 parents 264d51b + d27140b commit f09651f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
34 changes: 21 additions & 13 deletions isalt/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,26 @@ def _napalm_is_proxy(opts):
if saltenv not in __opts__.get('file_roots', {}):
__opts__['file_roots'] = {saltenv: []}
file_roots = __opts__['file_roots'][saltenv]
sproxy_path = salt_sproxy.__path__[0]
sproxy_path = list(salt_sproxy.__path__)[0]
if sproxy_path not in file_roots:
file_roots.append(sproxy_path)
__opts__['file_roots'][saltenv] = file_roots
if 'runner_dirs' not in __opts__:
__opts__['runner_dirs'] = []
sproxy_runner_path = os.path.join(sproxy_path, '_runners')
if sproxy_runner_path not in __opts__['runner_dirs']:
__opts__['runner_dirs'].append(sproxy_runner_path)
sproxy_dirs = [
sproxy_dir
for sproxy_dir in os.listdir(sproxy_path)
if sproxy_dir.startswith('_')
and not sproxy_dir.startswith('__')
and os.path.isdir(os.path.join(sproxy_path, sproxy_dir))
]
for sproxy_dir in sproxy_dirs:
sproxy_dirs_opts = '{}_dirs'.format(
sproxy_dir.replace('_', '', 1).replace('s', '', -1)
)
if sproxy_dirs_opts not in __opts__:
__opts__[sproxy_dirs_opts] = []
sproxy_dir_path = os.path.join(sproxy_path, sproxy_dir)
if sproxy_dir_path not in __opts__[sproxy_dirs_opts]:
__opts__[sproxy_dirs_opts].append(sproxy_dir_path)
__utils__ = salt.loader.utils(__opts__)
__salt__ = salt.loader.runner(__opts__, utils=__utils__)

Expand All @@ -355,16 +366,13 @@ def _napalm_is_proxy(opts):
ipy_cfg.TerminalInteractiveShell.term_title_format = 'ISalt'
else:
ipy_cfg.TerminalInteractiveShell.term_title = False
ipy_cfg.InteractiveShell.banner1 = (
BANNER
+ '''\n
ipy_cfg.InteractiveShell.banner1 = BANNER + '''\n
Role: {role}
Salt version: {salt_ver}
IPython version: {ipython_ver}\n'''.format(
role=role.title(),
salt_ver=salt.version.__version__,
ipython_ver=IPython.__version__,
)
role=role.title(),
salt_ver=salt.version.__version__,
ipython_ver=IPython.__version__,
)
IPython.start_ipython(config=ipy_cfg, user_ns=dunders)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name='isalt',
version='2021.2.0',
version='2021.2.1',
namespace_packages=['isalt'],
packages=find_packages(),
author='Mircea Ulinic',
Expand Down

0 comments on commit f09651f

Please sign in to comment.