Skip to content

Commit 8b332f1

Browse files
committed
cleanup remaining subprocess call
1 parent c6dad12 commit 8b332f1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

GSASII/GSASIIpath.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,24 +1581,21 @@ def addCondaPkg():
15811581
currenv = os.environ['CONDA_DEFAULT_ENV']
15821582
if sys.platform == "win32":
15831583
cmd = [os.environ['CONDA_EXE'],'install','conda','-n',currenv,'-y']
1584-
p = subprocess.Popen(cmd,
1584+
with subprocess.Popen(cmd,
15851585
#stdout=subprocess.PIPE,
1586-
stderr=subprocess.PIPE)
1586+
stderr=subprocess.PIPE,
1587+
encoding='UTF-8') as p:
1588+
out,err = p.communicate()
15871589
else:
15881590
script = 'source ' + os.path.join(
15891591
os.path.dirname(os.environ['CONDA_PYTHON_EXE']),
15901592
'activate') + ' base; '
15911593
script += 'conda install conda -n '+currenv+' -y'
1592-
p = subprocess.Popen(script,shell=True,env={},
1594+
with subprocess.Popen(script,shell=True,env={},
15931595
#stdout=subprocess.PIPE,
15941596
stderr=subprocess.PIPE,
1595-
encoding='UTF-8')
1596-
out,err = p.communicate()
1597-
p.terminate()
1598-
try:
1599-
p.wait(1)
1600-
except TimeoutExpired:
1601-
pass
1597+
encoding='UTF-8') as p:
1598+
out,err = p.communicate()
16021599

16031600
if out is not None and GetConfigValue('debug'): print('Output from adding conda:\n',out)
16041601
if err and err is not None:

0 commit comments

Comments
 (0)