forked from ungleich-public/cdist
Merge branch 'bugfix/in-script-import' into 'master'
Fix importing cdist module Closes #845 See merge request ungleich-public/cdist!957
This commit is contained in:
commit
d30cd5c2b2
1 changed files with 15 additions and 17 deletions
32
bin/cdist
32
bin/cdist
|
@ -25,25 +25,23 @@ import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# try to import cdist and if that fails,
|
# See if this file's parent is cdist module
|
||||||
# then add this file's parent dir to
|
# and if so add it to module search path.
|
||||||
# module search path and try again.
|
cdist_dir = os.path.realpath(
|
||||||
try:
|
os.path.join(
|
||||||
import cdist
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
except ModuleNotFoundError:
|
os.pardir))
|
||||||
cdist_dir = os.path.realpath(
|
cdist_init_dir = os.path.join(cdist_dir, 'cdist', '__init__.py')
|
||||||
os.path.join(
|
if os.path.exists(cdist_init_dir):
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
|
||||||
os.pardir))
|
|
||||||
sys.path.insert(0, cdist_dir)
|
sys.path.insert(0, cdist_dir)
|
||||||
import cdist
|
|
||||||
|
|
||||||
import cdist.argparse
|
import cdist # noqa 402
|
||||||
import cdist.banner
|
import cdist.argparse # noqa 402
|
||||||
import cdist.config
|
import cdist.banner # noqa 402
|
||||||
import cdist.install
|
import cdist.config # noqa 402
|
||||||
import cdist.shell
|
import cdist.install # noqa 402
|
||||||
import cdist.inventory
|
import cdist.shell # noqa 402
|
||||||
|
import cdist.inventory # noqa 402
|
||||||
|
|
||||||
|
|
||||||
def commandline():
|
def commandline():
|
||||||
|
|
Loading…
Reference in a new issue