Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to ignore error codes #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ def application(request):
payload = json.loads(request.data)
source_file.write(payload['contents'].decode('base64'))
options = payload.get('options', {})
ignoreErrors = payload.get('ignoreerrors',False)
elif request.files:
# First check if any files were uploaded
source_file.write(request.files['file'].read())
# Load any options that may have been provided in options
options = json.loads(request.form.get('options', '{}'))
# Optionally bypass any excpetions thrown from wkhtmltopdf
ignoreErrors = json.loads(request.form.get('ignoreerrors', 'false'))

source_file.flush()

Expand All @@ -56,7 +59,11 @@ def application(request):
args += [file_name, file_name + ".pdf"]

# Execute the command using executor
execute(' '.join(args))
try:
execute(' '.join(args))
except:
if not ignoreErrors:
raise

return Response(
wrap_file(request.environ, open(file_name + '.pdf')),
Expand Down