@@ -152,18 +152,6 @@ def get_base_dirs():
152
152
return basedir_map .get (sys .platform , ['/usr/local' , '/usr' ])
153
153
154
154
155
- def run_child_process (cmd ):
156
- """
157
- Run a subprocess as a sanity check.
158
- """
159
- p = subprocess .Popen (cmd , shell = True ,
160
- stdin = subprocess .PIPE ,
161
- stdout = subprocess .PIPE ,
162
- stderr = subprocess .STDOUT ,
163
- close_fds = (sys .platform != 'win32' ))
164
- return p .stdin , p .stdout
165
-
166
-
167
155
def is_min_version (found , minversion ):
168
156
"""
169
157
Returns `True` if `found` is at least as high a version as
@@ -1708,9 +1696,10 @@ class DviPng(SetupPackage):
1708
1696
1709
1697
def check (self ):
1710
1698
try :
1711
- stdin , stdout = run_child_process ('dvipng -version' )
1712
- return "version %s" % stdout .readlines ()[1 ].decode ().split ()[- 1 ]
1713
- except (IndexError , ValueError ):
1699
+ output = check_output ('dvipng -version' , shell = True ,
1700
+ stderr = subprocess .STDOUT )
1701
+ return "version %s" % output .splitlines ()[1 ].decode ().split ()[- 1 ]
1702
+ except (IndexError , ValueError , subprocess .CalledProcessError ):
1714
1703
raise CheckFailed ()
1715
1704
1716
1705
@@ -1722,11 +1711,19 @@ def check(self):
1722
1711
try :
1723
1712
if sys .platform == 'win32' :
1724
1713
command = 'gswin32c --version'
1714
+ try :
1715
+ output = check_output (command , shell = True ,
1716
+ stderr = subprocess .STDOUT )
1717
+ except subprocess .CalledProcessError :
1718
+ command = 'gswin64c --version'
1719
+ output = check_output (command , shell = True ,
1720
+ stderr = subprocess .STDOUT )
1725
1721
else :
1726
1722
command = 'gs --version'
1727
- stdin , stdout = run_child_process (command )
1728
- return "version %s" % stdout .read ().decode ()[:- 1 ]
1729
- except (IndexError , ValueError ):
1723
+ output = check_output (command , shell = True ,
1724
+ stderr = subprocess .STDOUT )
1725
+ return "version %s" % output .decode ()[:- 1 ]
1726
+ except (IndexError , ValueError , subprocess .CalledProcessError ):
1730
1727
raise CheckFailed ()
1731
1728
1732
1729
@@ -1736,12 +1733,13 @@ class LaTeX(SetupPackage):
1736
1733
1737
1734
def check (self ):
1738
1735
try :
1739
- stdin , stdout = run_child_process ('latex -version' )
1740
- line = stdout .readlines ()[0 ].decode ()
1736
+ output = check_output ('latex -version' , shell = True ,
1737
+ stderr = subprocess .STDOUT )
1738
+ line = output .splitlines ()[0 ].decode ()
1741
1739
pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)'
1742
1740
match = re .search (pattern , line )
1743
1741
B004
return "version %s" % match .group (0 )
1744
- except (IndexError , ValueError , AttributeError ):
1742
+ except (IndexError , ValueError , AttributeError , subprocess . CalledProcessError ):
1745
1743
raise CheckFailed ()
1746
1744
1747
1745
@@ -1751,12 +1749,13 @@ class PdfToPs(SetupPackage):
1751
1749
1752
1750
def check (self ):
1753
1751
try :
1754
- stdin , stdout = run_child_process ('pdftops -v' )
1755
- for line in stdout .readlines ():
1752
+ output = check_output ('pdftops -v' , shell = True ,
1753
+ stderr = subprocess .STDOUT )
1754
+ for line in output .splitlines ():
1756
1755
line = line .decode ()
1757
1756
if 'version' in line :
1758
1757
return "version %s" % line .split ()[2 ]
1759
- except (IndexError , ValueError ):
1758
+ except (IndexError , ValueError , subprocess . CalledProcessError ):
1760
1759
pass
1761
1760
1762
1761
raise CheckFailed ()
0 commit comments