diff --git a/confluent_server/confluent/networking/macmap.py b/confluent_server/confluent/networking/macmap.py index a9c6b86a..d1377dbf 100644 --- a/confluent_server/confluent/networking/macmap.py +++ b/confluent_server/confluent/networking/macmap.py @@ -31,7 +31,14 @@ # this module will provide mac to switch and full 'ifName' label # This functionality is restricted to the null tenant +import os +import sys + if __name__ == '__main__': + path = os.path.dirname(os.path.realpath(__file__)) + path = os.path.realpath(os.path.join(path, '..', '..')) + if path.startswith('/opt'): + sys.path.append(path) import confluent.config.configmanager as cfm import confluent.snmputil as snmp @@ -43,8 +50,6 @@ import eventlet.green.select as select import eventlet.green.socket as socket -import os -import sys import confluent.exceptions as exc import confluent.log as log import confluent.messages as msg @@ -690,10 +695,6 @@ def rescan(cfg): if __name__ == '__main__': - path = os.path.dirname(os.path.realpath(__file__)) - path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) - if path.startswith('/opt'): - sys.path.append(path) if len(sys.argv) > 1 and sys.argv[1] == '-o': try: upacker = msgpack.Unpacker(encoding='utf8') diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index c6454235..b1643135 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -1,6 +1,4 @@ #!/usr/bin/python -import confluent.exceptions as exc -import confluent.messages as msg import eventlet import eventlet.green.select as select import eventlet.green.subprocess as subprocess @@ -14,6 +12,14 @@ import shutil import sys import time import yaml +if __name__ == '__main__': + path = os.path.dirname(os.path.realpath(__file__)) + path = os.path.realpath(os.path.join(path, '..')) + if path.startswith('/opt'): + sys.path.append(path) + +import confluent.exceptions as exc +import confluent.messages as msg COPY = 1 EXTRACT = 2 @@ -930,10 +936,6 @@ def get_importing_status(importkey): if __name__ == '__main__': os.umask(0o022) - path = os.path.dirname(os.path.realpath(__file__)) - path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) - if path.startswith('/opt'): - sys.path.append(path) if len(sys.argv) > 2: mfd = os.environ.get('CONFLUENT_MEDIAFD', None) sys.exit(import_image(sys.argv[1], callback=printit, backend=True, mfd=mfd))