2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Avoid modifying PYTHONPATH

Since there's a possibility of cross-python invocation,
avoid modifying PYTHONPATH
This commit is contained in:
Jarrod Johnson 2023-07-05 11:40:00 -04:00
parent 7ddd2c2e6e
commit 052d16aa49
2 changed files with 9 additions and 2 deletions

View File

@ -208,7 +208,6 @@ def _offload_map_switch(switch, password, user):
def _start_offloader():
global _offloader
os.environ['PYTHONPATH'] = ':'.join(sys.path)
_offloader = subprocess.Popen(
[sys.executable, __file__, '-o'], bufsize=0, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
@ -691,6 +690,10 @@ 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')

View File

@ -861,7 +861,6 @@ class MediaImporter(object):
return {'phase': self.phase, 'progress': self.percent, 'profiles': self.profiles, 'error': self.error}
def importmedia(self):
os.environ['PYTHONPATH'] = ':'.join(sys.path)
if self.medfile:
os.environ['CONFLUENT_MEDIAFD'] = '{0}'.format(self.medfile.fileno())
with open(os.devnull, 'w') as devnull:
@ -931,8 +930,13 @@ 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))
else:
sys.exit(import_image(sys.argv[1], callback=printit))