1
0
Fork 0
mirror of synced 2024-06-01 10:09:49 +12:00

wget images too, print stderr on fail

This commit is contained in:
Nick Sweeting 2017-07-04 02:42:29 -05:00
parent 1431cc3290
commit 263f71862a

View file

@ -158,10 +158,12 @@ def fetch_wget(out_dir, link, overwrite=False):
print(' - Downloading Full Site')
CMD = [
*'wget --no-clobber --page-requisites --adjust-extension --convert-links --no-parent'.split(' '),
link['url'],
]
try:
run(CMD, stdout=DEVNULL, stderr=DEVNULL, cwd=out_dir, timeout=20) # dom.html
output = run(CMD, stdout=DEVNULL, stderr=PIPE, cwd=out_dir, timeout=20) # dom.html
if output.returncode:
print(output.stderr.read())
raise Exception('Failed to wget download')
except Exception as e:
print(' Exception: {} {}'.format(e.__class__.__name__, e))
else:
@ -174,8 +176,9 @@ def fetch_pdf(out_dir, link, overwrite=False):
print(' - Printing PDF')
chrome_args = '--headless --disable-gpu --print-to-pdf'.split(' ')
try:
run([CHROME_BINARY, *chrome_args, link['url']], stdout=DEVNULL, stderr=DEVNULL, cwd=out_dir, timeout=20) # output.pdf
result = run([CHROME_BINARY, *chrome_args, link['url']], stdout=DEVNULL, stderr=PIPE, cwd=out_dir, timeout=20) # output.pdf
if run(['chmod', ARCHIVE_PERMISSIONS, 'output.pdf'], stdout=DEVNULL, stderr=DEVNULL, timeout=5).returncode:
print(result.stderr.read())
raise Exception('Failed to print PDF')
except Exception as e:
print(' Exception: {} {}'.format(e.__class__.__name__, e))
@ -189,8 +192,9 @@ def fetch_screenshot(out_dir, link, overwrite=False):
print(' - Snapping Screenshot')
chrome_args = '--headless --disable-gpu --screenshot'.split(' ')
try:
run([CHROME_BINARY, *chrome_args, '--window-size={}'.format(RESOLUTION), link['url']], stdout=DEVNULL, stderr=DEVNULL, cwd=out_dir, timeout=20) # sreenshot.png
result = run([CHROME_BINARY, *chrome_args, '--window-size={}'.format(RESOLUTION), link['url']], stdout=DEVNULL, stderr=DEVNULL, cwd=out_dir, timeout=20) # sreenshot.png
if run(['chmod', ARCHIVE_PERMISSIONS, 'screenshot.png'], stdout=DEVNULL, stderr=DEVNULL, timeout=5).returncode:
print(result.stderr.read())
raise Exception('Failed to take screenshot')
except Exception as e:
print(' Exception: {} {}'.format(e.__class__.__name__, e))