References:
https://github.com/tesseract-ocr/tesseract/wiki/Compiling
http://stackoverflow.com/questions/33588262/tesseract-ocr-on-aws-lambda-via-virtualenv
svg = """ | |
<path d="M 680.40768,58.690197 C 680.17329,58.760524 680.10297,59.018351 680.22018,59.440197 C 680.47016,59.783987 680.47015,61.533977 680.18893,64.690197 C 677.50142,64.783977 674.53266,64.752738 671.31393,64.627697 L 671.12643,64.721447 C 671.22017,65.971477 671.28266,67.346466 671.31393,68.846447 C 674.40767,68.721467 677.28265,68.596477 679.90768,68.440197 C 679.78267,70.752727 679.72015,73.377716 679.75143,76.346447 C 677.90766,77.158957 676.28265,78.190218 674.84518,79.440197 C 673.40767,80.690217 672.22016,82.221457 671.31393,84.033947 C 670.43892,85.815207 670.06391,87.783957 670.15768,89.940197 C 670.25143,92.065207 670.78266,93.752697 671.75143,94.971447 C 672.75142,96.158947 674.06391,96.846447 675.72018,97.065197 C 677.37641,97.315197 678.9389,97.096447 680.37643,96.377697 C 681.81391,95.690197 682.90764,95.065197 683.65768,94.533947 L 684.25143,96.033947 C 686.31391,94.908947 687.81389,94.221447 688.72018,93.940197 L 688.75143,93.408947 C 688.28265,92.565197 687.84514,91.752697 687.4389 |
from threading import Lock | |
from botocore.endpoint import Endpoint | |
import botocore.session | |
import treq | |
__all__ = ('AWSClient',) | |
import binascii | |
import hashlib | |
import os | |
# Max size in bytes before uploading in parts | |
AWS_UPLOAD_MAX_SIZE = 20 * 1024 * 1024 | |
# Size of parts when uploading in parts | |
# make sure you use upload part size the same as your client | |
# be careful, botocore put_object can't do multipart: |
AWS Lambda allows you to run custom binaries as child processes.
However, if the packaged binary you're running on AWS Lambda uses shared libraries, they may not be available in the Lambda environment. If this is the case, your binary will terminate without any output. In my case, the exit status code was 127
, which wasn't very helpful (typically this is "command not found.")
2015-11-18T00:50:10.731Z 521db901-8d8e-11e5-b9df-cd31cc90ece2 Calling phantom: /var/task/phantomjs [ '/var/task/phantomjs-script.js' ]
2015-11-18T00:50:10.809Z 521db901-8d8e-11e5-b9df-cd31cc90ece2 child process exited with code 127
Linux's loader, ld.so, allows you (see manpage) to set an environment variable called LD_DEBUG
that will output verbose information while the shared libraries are loaded.
Since Lambda doesn't let you set arbitrary environment variables, you need to set the environment
import asyncio | |
import hashlib | |
import hmac | |
import time | |
from urllib.parse import urljoin, urlencode | |
import aiohttp | |
import async_timeout | |
import hmac | |
import json | |
from hashlib import sha1 | |
from django.views.decorators.csrf import csrf_exempt | |
@csrf_exempt | |
def pull_view(request): | |
""" |