@@ -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
@@ -1709,9 +1697,10 @@ class DviPng(SetupPackage):
1709
1697
1710
1698
def check (self ):
1711
1699
try :
1712
- stdin , stdout = run_child_process ('dvipng -version' )
1713
- return "version %s" % stdout .readlines ()[1 ].decode ().split ()[- 1 ]
1714
- except (IndexError , ValueError ):
1700
+ output = check_output ('dvipng -version' , shell = True ,
1701
+ stderr = subprocess .STDOUT )
1702
+ return "version %s" % output .splitlines ()[1 ].decode ().split ()[- 1 ]
1703
+ except (IndexError , ValueError , subprocess .CalledProcessError ):
1715
1704
raise CheckFailed ()
1716
1705
1717
1706
@@ -1723,11 +1712,19 @@ def check(self):
1723
1712
try :
1724
1713
if sys .platform == 'win32' :
1725
1714
command = 'gswin32c --version'
1715
+ try :
1716
+ output = check_output (command , shell = True ,
1717
+ stderr = subprocess .STDOUT )
1718
+ except subprocess .CalledProcessError :
1719
+ command = 'gswin64c --version'
1720
+ output = check_output (command , shell = True ,
1721
+ stderr = subprocess .STDOUT )
1726
1722
else :
1727
1723
command = 'gs --version'
1728
- stdin , stdout = run_child_process (command )
1729
- return "version %s" % stdout .read ().decode ()[:- 1 ]
1730
- except (IndexError , ValueError ):
1724
+ output = check_output (command , shell = True ,
1725
+ stderr = subprocess .STDOUT )
1726
+ return "version %s" % output .decode ()[:- 1 ]
1727
+ except (IndexError , ValueError , subprocess .CalledProcessError ):
1731
1728
raise CheckFailed ()
1732
1729
1733
1730
@@ -1737,12 +1734,13 @@ class LaTeX(SetupPackage):
1737
1734
1738
1735
def check (self ):
1739
1736
try :
1740
- stdin , stdout = run_child_process ('latex -version' )
1741
- line = stdout .readlines ()[0 ].decode ()
1737
+ output = check_output ('latex -version' , shell = True ,
1738
+ stderr = subprocess .STDOUT )
1739
+ line = output .splitlines ()[0 ].decode ()
1742
1740
pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)'
1743
1741
match = re .search (pattern , line )
1744
1742
return "version %s" % match .group (0 )
1745
- except (IndexError , ValueError , AttributeError ):
1743
+ except (IndexError , ValueError , AttributeError , subprocess . CalledProcessError ):
1746
1744
raise CheckFailed ()
1747
1745
1748
1746
@@ -1752,12 +1750,13 @@ class PdfToPs(SetupPackage):
1752
1750
1753
1751
def check (self ):
1754
1752
try :
1755
- stdin , stdout = run_child_process ('pdftops -v' )
1756
- for line in stdout .readlines ():
1753
+ output = check_output ('pdftops -v' , shell = True ,
1754
+ stderr = subprocess .STDOUT )
1755
+ for line in output .splitlines ():
1757
1756
line = line .decode ()
1758
1757
if 'version' in line :
1759
1758
return "version %s" % line .split ()[2 ]
1760
- except (IndexError , ValueError ):
1759
+ except (IndexError , ValueError , subprocess . CalledProcessError ):
1761
1760
pass
1762
1761
1763
1762
raise CheckFailed ()
0 commit comments