Skip to content

Commit 1ea3c61

Browse files
authored
Merge pull request hpcugent#339 from wdpypere/remove_popen
fix unclosed resource
2 parents dc882d3 + 9e5b803 commit 1ea3c61

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/vsc/utils/generaloption.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import sys
3939
import textwrap
4040
import configparser
41+
import subprocess
4142
from functools import reduce
4243
from optparse import OptionParser, OptionGroup, Option, Values
4344
from optparse import BadOptionError, SUPPRESS_USAGE, OptionValueError
@@ -66,9 +67,8 @@ def set_columns(cols=None):
6667
if cols is None:
6768
if os.path.exists(STTY):
6869
try:
69-
proc = os.popen('%s size 2>/dev/null' % STTY)
70-
cols = int(proc.read().strip().split(' ')[1])
71-
proc.close()
70+
proc = subprocess.run(['/usr/bin/stty', 'size'], stdout=subprocess.PIPE)
71+
cols = str(proc.stdout.splitlines()[0].decode('utf-8').split(' ')[1])
7272
except (AttributeError, IndexError, OSError, ValueError):
7373
# do nothing
7474
pass

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from vsc.install.shared_setup import ag, kh, jt, sdw
3838

3939
PACKAGE = {
40-
'version': '3.5.1',
40+
'version': '3.5.2',
4141
'author': [sdw, jt, ag, kh],
4242
'maintainer': [sdw, jt, ag, kh],
4343
'install_requires': [

0 commit comments

Comments
 (0)