diff --git a/.travis.yml b/.travis.yml index efd3ae568..5e4393810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ install: - pip install pyyaml - pip install flask - pip install six +- pip install pypandoc before_script: - mkdir prism - mkdir prism/bin @@ -20,6 +21,16 @@ before_script: script: - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then unit2 discover; else python -m unittest discover; fi +before_deploy: +- python ./register.py +deploy: + provider: pypi + user: thinkingserious + password: + secure: DoM21KiMKkt/7AS6zOqTs7j3fgInrpswRTPG3cqBNRSzyfkXeXmKecCPruooxvYKLM7fPNDOuIH2phgCjdx/XBtJwghNh34n+TzhNFEiI/6pV0iS4a9gW0+QU+GMYvQmfNlA9DKQ5N20FMy4XeK8QQFarJXQwW1/a5wWftbUYvQ= + distributions: sdist bdist_wheel + on: + tags: true notifications: hipchat: rooms: diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index c22913108..84143ca95 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -4,39 +4,29 @@ If you can't find a solution below, please open an [issue](https://github.com/se ## Table of Contents +* [Environment Variables and Your SendGrid API Key](#environment) +* [Error Messages](#error) * [Migrating from v2 to v3](#migrating) * [Continue Using v2](#v2) * [Testing v3 /mail/send Calls Directly](#testing) -* [Error Messages](#error) -* [Versions](#versions) -* [Environment Variables and Your SendGrid API Key](#environment) * [Using the Package Manager](#package-manager) +* [Version Convention](#versions) +* [Viewing the Request Body](#request-body) - -## Migrating from v2 to v3 - -Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) on how to migrate from v2 to v3. - - -## Continue Using v2 - -[Here](https://github.com/sendgrid/sendgrid-python/tree/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7) is the last working version with v2 support. + +## Environment Variables and Your SendGrid API Key -Using pip: +All of our examples assume you are using [environment variables](https://github.com/sendgrid/sendgrid-python#setup-environment-variables) to hold your SendGrid API key. -```bash -pip uninstall sendgrid -pip install sendgrid=1.6.22 -``` +If you choose to add your SendGrid API key directly (not recommended): -Download: +`apikey=os.environ.get('SENDGRID_API_KEY')` -Click the "Clone or download" green button in [GitHub](https://github.com/sendgrid/sendgrid-python/tree/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7) and choose download. +becomes - -## Testing v3 /mail/send Calls Directly +`apikey='SENDGRID_API_KEY'` -[Here](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/curl_examples.html) are some cURL examples for common use cases. +In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key. ## Error Messages @@ -61,25 +51,32 @@ try: except urllib.error.HTTPError as e: print e.read() ``` - -## Versions -We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guarenteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases) section. + +## Migrating from v2 to v3 - -## Environment Variables and Your SendGrid API Key +Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) on how to migrate from v2 to v3. -All of our examples assume you are using [environment variables](https://github.com/sendgrid/sendgrid-python#setup-environment-variables) to hold your SendGrid API key. + +## Continue Using v2 -If you choose to add your SendGrid API key directly (not recommended): +[Here](https://github.com/sendgrid/sendgrid-python/tree/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7) is the last working version with v2 support. -`apikey=os.environ.get('SENDGRID_API_KEY')` +Using pip: -becomes +```bash +pip uninstall sendgrid +pip install sendgrid=1.6.22 +``` -`apikey='SENDGRID_API_KEY'` +Download: -In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key. +Click the "Clone or download" green button in [GitHub](https://github.com/sendgrid/sendgrid-python/tree/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7) and choose download. + + +## Testing v3 /mail/send Calls Directly + +[Here](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/curl_examples.html) are some cURL examples for common use cases. ## Using the Package Manager @@ -93,3 +90,19 @@ In most cases we recommend you download the latest version of the library, but i If you are usring a [requirements file](https://pip.readthedocs.io/en/1.1/requirements.html), please use: `sendgrid==X.X.X` + + +## Versioning Convention + +We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guarenteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases) section. + + +## Viewing the Request Body + +When debugging or testing, it may be useful to exampine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html). + +You can do this right before you call `response = sg.client.mail.send.post(request_body=mail.get())` like so: + +```python +print mail.get() +``` \ No newline at end of file diff --git a/register.py b/register.py index 23feaf5a8..73aaf5c4e 100644 --- a/register.py +++ b/register.py @@ -4,4 +4,11 @@ output = pypandoc.convert('README.md', 'rst') f = open('README.txt','w+') f.write(output) -f.close() \ No newline at end of file +f.close() + +readme_rst = open('./README.txt').read() +replace = '.. figure:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png\n :alt: SendGrid Logo\n\n SendGrid Logo\n' +replacement = '|SendGrid Logo|\n\n.. |SendGrid Logo| image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png\n :target: https://www.sendgrid.com' +final_text = readme_rst.replace(replace,replacement) +with open('./README.txt', 'w') as f: + f.write(final_text)