@@ -1421,34 +1421,12 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
1421
1421
latexfile = latexfile .replace ("\\ " , "/" )
1422
1422
# Replace ~ so Latex does not think it is line break
1423
1423
latexfile = latexfile .replace ("~" , "\\ string~" )
1424
- command = ["latex" , "-interaction=nonstopmode" , '"%s"' % latexfile ]
1425
- _log .debug ('%s' , command )
1426
- try :
1427
- report = subprocess .check_output (command , cwd = tmpdir ,
1428
- stderr = subprocess .STDOUT )
1429
- except subprocess .CalledProcessError as exc :
1430
- raise RuntimeError (
1431
- ('LaTeX was not able to process the following '
1432
- 'file:\n %s\n \n '
1433
- 'Here is the full report generated by LaTeX:\n %s '
1434
- '\n \n ' % (latexfile ,
1435
- exc .output .decode ("utf-8" ))))
1436
- _log .debug (report )
1437
-
1438
- command = ['dvips' , '-q' , '-R0' , '-o' , os .path .basename (psfile ),
1439
- os .path .basename (dvifile )]
1440
- _log .debug (command )
1441
- try :
1442
- report = subprocess .check_output (command , cwd = tmpdir ,
1443
- stderr = subprocess .STDOUT )
1444
- except subprocess .CalledProcessError as exc :
1445
- raise RuntimeError (
1446
- ('dvips was not able to process the following '
1447
- 'file:\n %s\n \n '
1448
- 'Here is the full report generated by dvips:\n %s '
1449
- '\n \n ' % (dvifile ,
1450
- exc .output .decode ("utf-8" ))))
1451
- _log .debug (report )
1424
+
1425
+ cbook ._check_and_log_subprocess (
1426
+ ["latex" , "-interaction=nonstopmode" , '"%s"' % latexfile ])
1427
+ cbook ._check_and_log_subprocess (
1428
+ ['dvips' , '-q' , '-R0' , '-o' , os .path .basename (psfile ),
1429
+ os .path .basename (dvifile )], cwd = tmpdir )
1452
1430
os .remove (epsfile )
1453
1431
shutil .move (psfile , tmpfile )
1454
1432
@@ -1493,18 +1471,11 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
1493
1471
else :
1494
1472
device_name = "pswrite"
1495
1473
1496
- command = [str (gs_exe ), "-dBATCH" , "-dNOPAUSE" , "-r%d" % dpi ,
1497
- "-sDEVICE=%s" % device_name , paper_option ,
1498
- "-sOutputFile=%s" % psfile , tmpfile ]
1499
- _log .debug (command )
1500
- try :
1501
- report = subprocess .check_output (command , stderr = subprocess .STDOUT )
1502
- except subprocess .CalledProcessError as exc :
1503
- raise RuntimeError (
1504
- ('ghostscript was not able to process your image.\n '
1505
- 'Here is the full report generated by ghostscript:\n %s '
1506
- '\n \n ' % exc .output .decode ("utf-8" )))
1507
- _log .debug (report )
1474
+ cbook ._check_and_log_subprocess (
1475
+ [gs_exe , "-dBATCH" , "-dNOPAUSE" , "-r%d" % dpi ,
1476
+ "-sDEVICE=%s" % device_name , paper_option ,
1477
+ "-sOutputFile=%s" % psfile , tmpfile ])
1478
+
1508
1479
os .remove (tmpfile )
1509
1480
shutil .move (psfile , tmpfile )
1510
1481
@@ -1535,35 +1506,18 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
1535
1506
1536
1507
# Pass options as `-foo#bar` instead of `-foo=bar` to keep Windows happy
1537
1508
# (https://www.ghostscript.com/doc/9.22/Use.htm#MS_Windows).
1538
- command = ["ps2pdf" ,
1539
- "-dAutoFilterColorImages#false" ,
1540
- "-dAutoFilterGrayImages#false" ,
1541
- "-dAutoRotatePages#false" ,
1542
- "-sGrayImageFilter#FlateEncode" ,
1543
- "-sColorImageFilter#FlateEncode" ,
1544
- "-dEPSCrop" if eps else "-sPAPERSIZE#%s" % ptype ,
1545
- tmpfile , pdffile ]
1546
- _log .debug (command )
1547
-
1548
- try :
1549
- report = subprocess .check_output (command , stderr = subprocess .STDOUT )
1550
- except subprocess .CalledProcessError as exc :
1551
- raise RuntimeError (
1552
- ('ps2pdf was not able to process your image.\n '
1553
- 'Here is the full report generated by ps2pdf:\n %s '
1554
- '\n \n ' % exc .output .decode ("utf-8" )))
1555
- _log .debug (report )
1509
+ cbook ._check_and_log_subprocess (
1510
+ ["ps2pdf" ,
1511
+ "-dAutoFilterColorImages#false" ,
1512
+ "-dAutoFilterGrayImages#false" ,
1513
+ "-dAutoRotatePages#false" ,
1514
+ "-sGrayImageFilter#FlateEncode" ,
1515
+ "-sColorImageFilter#FlateEncode" ,
1516
+ "-dEPSCrop" if eps else "-sPAPERSIZE#%s" % ptype ,
1517
+ tmpfile , pdffile ])
1518
+ cbook ._check_and_log_subprocess (
1519
+ ["pdftops" , "-paper" , "match" , "-level2" , pdffile , psfile ])
1556
1520
1557
- command = ["pdftops" , "-paper" , "match" , "-level2" , pdffile , psfile ]
1558
- _log .debug (command )
1559
- try :
1560
- report = subprocess .check_output (command , stderr = subprocess .STDOUT )
1561
- except subprocess .CalledProcessError as exc :
1562
- raise RuntimeError (
1563
- ('pdftops was not able to process your image.\n '
1564
- 'Here is the full report generated by pdftops:\n %s '
1565
- '\n \n ' % exc .output .decode ("utf-8" )))
1566
- _log .debug (report )
1567
1521
os .remove (tmpfile )
1568
1522
shutil .move (psfile , tmpfile )
1569
1523
0 commit comments