Verifying your license works
If you have purchased a commercial licence you should receive a licence file.
-
Make sure any expired/old licence files (ReportLabPLUSLicense.py) are deleted (along with the corresponding .pyc).
-
Make sure that the new file is copied into a directory anywhere on the PYTHONPATH. Typically, if you are running a Python script from a terminal the current working directory should be on the path. You can always check the path in a terminal, start python, then ;
>>> import sys
>>> sys.path
-
Verify by checking:
-the licence can be imported,
-the path of the file,
-the licence number (eg when the the licence was issued),
-the user field looks right,
-check the expiry date
-Example verification:
$ python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ReportLabPLUSLicense >>> ReportLabPLUSLicense.__file__ 'ReportLabPLUSLicense.py' >>>ReportLabPLUSLicense.number '20200323095038' >>> ReportLabPLUSLicense.user 'customer-{optional-comment}-year-issued' >>>import time >>>time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(ReportLabPLUSLicense.expire)) '2020-09-19 01:00:00'
Using the license file as a secret on a server
If you don't want to leave license files exposed on a server unencrypted,
one way to get around this is to use secrets.
In versions of rlextra past 4.4.1.2 we can do this through environment variables.
The key is REPORTLAB_PLUS_LICENCE
and the value should be the base64 encoded license file text.
You can get the b64 encoded license using:
$ python -m rlextra.utils.ubold /home/rptlab-fuji/bin/ReportLabPLUSLicense.py
REPORTLAB_PLUS_LICENCE="<b64 license value here>"
Testing environment loading locally
If you want to test that using environment variables works locally, you can run the following where we've written the encoded contents to a file, or load it any other preferred way you may have (e.g. directly), and then generate the pdf.
$ export REPORTLAB_PLUS_LICENCE=$(cat ~/bin/encoded_license.txt)
AWS Lambda functions
- Create the secret with name
REPORTLAB_PLUS_LICENSE
using the value above - Create a policy to allow your function to get the secret, see the AWS docs
- Attach the policy to your lambda function's execution role
- Add a
AWS-Parameters-and-Secrets-Lambda-Extension
layer to your lambda function - Fetch secret using sample code on the secret's page and set it on
os.environ['REPORTLAB_PLUS_LICENCE']