Skip to content

Verifying your license works

If you have purchased a commercial licence you should receive a licence file.

  1. Make sure any expired/old licence files (ReportLabPLUSLicense.py) are deleted (along with the corresponding .pyc).

  2. 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

  3. 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>"
If it returns nothing, your version of rlextra is incorrect. The value when used should not include the quotes. You now have a key and value pairing that can be used with secrets on your server.

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

  1. Create the secret with name REPORTLAB_PLUS_LICENSE using the value above
  2. Create a policy to allow your function to get the secret, see the AWS docs
  3. Attach the policy to your lambda function's execution role
  4. Add a AWS-Parameters-and-Secrets-Lambda-Extension layer to your lambda function
  5. Fetch secret using sample code on the secret's page and set it on os.environ['REPORTLAB_PLUS_LICENCE']