Skip to content

Commit 20874db

Browse files
authored
Merge pull request #5 from trustpilot/specify-user-agent
Specify user agent
2 parents 6b22021 + 0c3c3df commit 20874db

File tree

16 files changed

+522
-578
lines changed

16 files changed

+522
-578
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ python:
1212

1313
install:
1414
- pip install -U pip
15-
- pip install pypandoc
1615
- pip install .[test]
1716
- if [[ $TRAVIS_PYTHON_VERSION != 2.7 ]]; then pip install .[async]; fi
1817

HISTORY.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
## History
2+
3+
### 0.1.0 (2016-11-09)
4+
5+
- First release on gemfury
6+
7+
### 0.1.1 (2016-11-09)
8+
9+
- change names
10+
11+
### 0.1.2 (2016-11-09)
12+
13+
- fix issue with 401-retry
14+
15+
### 0.1.3 (2016-11-10)
16+
17+
- add dependencies to setup.py
18+
19+
### 0.1.4 (2016-11-11)
20+
21+
- cli tool
22+
23+
### 0.1.5 (2016-11-11)
24+
25+
- fix apikey url query param error
26+
27+
### 0.1.6 (2016-11-11)
28+
29+
- introduce different token\_issuer\_host thatn api\_host
30+
31+
### 0.1.7 (2016-12-06)
32+
33+
- Introduce context\_getter on session object, defaulted to holding
34+
CorrelationId=random\_uuid
35+
36+
### 1.0.0 (2017-02-01)
37+
38+
- first release as oss, major refactoring of inner machinery (session
39+
objects, retry policies, cli, tests etc)
40+
41+
### 1.1.0 (2017-06-12)
42+
43+
- fixed logging so it does not use root logger. according to best
44+
practices mentioned in
45+
<http://pythonsweetness.tumblr.com/post/67394619015/use-of-logging-package-from-within-a-library>
46+
- removed dependency on httpretty since it is not supporting py3
47+
48+
### 2.0.0 (2017-09-29)
49+
50+
- DEPRECATED: create\_session is getting deprecated, use
51+
trustpilot.client.default\_session.setup instead
52+
- now able to query public endpoints without being authenticated
53+
54+
### 2.1.0 (2017-10-05)
55+
56+
- fixed issue in cli.post & cli.put where 'content\_type' should be
57+
'content-type'
58+
59+
### 3.0.0 (2018-01-18)
60+
61+
DELETED DO NOT USE\!\!
62+
63+
- add async-client
64+
65+
### 3.0.1 (2018-01-18)
66+
67+
- removed prints
68+
- made async\_client retry on unauthorized
69+
70+
### 4.0.0 (2018-06-06)
71+
72+
- drop support for Python 3.3
73+
74+
### 4.0.1 (2018-06-06)
75+
76+
- Switch to non-deprecated session object for utility method calls
77+
78+
### 4.0.2 (2018-10-30)
79+
80+
- Upgrade requests to 2.20.0
81+
82+
### 5.0.0 (2019-01-04)
83+
84+
- Update to authentication methods
85+
86+
### 5.0.1 (2019-02-04)
87+
88+
- Fix documentation formatting
89+
90+
### 6.0.0 (2019-02-06)
91+
92+
- reorganize code
93+
- add user-agent header
94+
- get access\_token with async call in async\_client
95+
96+
### 6.0.3 (2019-08-15)
97+
98+
- Added support for 'API Version' parameter for Client initialisation.
99+
100+
### 6.0.4 (2019-08-15)
101+
102+
- Remove auto-deploy to travis
103+
104+
### 6.0.5 (2019-08-15)
105+
106+
- allow newer version of requests dependency
107+
108+
### 6.0.6 (2019-09-18)
109+
110+
- specify user agent through env-var or kwarg

HISTORY.rst

Lines changed: 0 additions & 127 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

2-
include CONTRIBUTING.rst
3-
include HISTORY.rst
2+
include HISTORY.md
43
include README.md
54

65
recursive-include tests *

Makefile

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,4 @@
1-
.PHONY: clean clean-test clean-pyc clean-build docs help
2-
.DEFAULT_GOAL := help
3-
define BROWSER_PYSCRIPT
4-
import os, webbrowser, sys
5-
try:
6-
from urllib import pathname2url
7-
except:
8-
from urllib.request import pathname2url
9-
10-
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
11-
endef
12-
export BROWSER_PYSCRIPT
13-
14-
define PRINT_HELP_PYSCRIPT
15-
import re, sys
16-
17-
for line in sys.stdin:
18-
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
19-
if match:
20-
target, help = match.groups()
21-
print("%-20s %s" % (target, help))
22-
endef
23-
export PRINT_HELP_PYSCRIPT
24-
BROWSER := python -c "$$BROWSER_PYSCRIPT"
25-
26-
help:
27-
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
28-
29-
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
30-
31-
32-
clean-build: ## remove build artifacts
33-
rm -fr build/
34-
rm -fr dist/
35-
rm -fr .eggs/
36-
find . -name '*.egg-info' -exec rm -fr {} +
37-
find . -name '*.egg' -exec rm -f {} +
38-
39-
clean-pyc: ## remove Python file artifacts
40-
find . -name '*.pyc' -exec rm -f {} +
41-
find . -name '*.pyo' -exec rm -f {} +
42-
find . -name '*~' -exec rm -f {} +
43-
find . -name '__pycache__' -exec rm -fr {} +
44-
45-
clean-test: ## remove test and coverage artifacts
46-
rm -fr .tox/
47-
rm -f .coverage
48-
rm -fr htmlcov/
49-
rm -f test_readme.py
50-
51-
52-
lint: ## check style with flake8
53-
flake8 python_simple_trustpilo_api_client tests
54-
55-
test: ## run tests quickly with the default Python
56-
py.test
57-
58-
tox: ## run tests quickly with the default Python
59-
rm -rf .tox
60-
detox
61-
62-
test-all: clean ## run all versions/tests with dtox (dockerized)
63-
@echo "Running all tests in Docker using dtox"
64-
rm -rf .tox
65-
docker run --rm -it -v "$$PWD":/src:ro realcundo/dtox "$$PWD"
66-
67-
coverage: ## check code coverage quickly with the default Python
68-
coverage run --source python_simple_trustpilo_api_client -m pytest
69-
70-
coverage report -m
71-
coverage html
72-
$(BROWSER) htmlcov/index.html
73-
74-
release: clean ## package and upload a release
75-
python setup.py sdist upload
76-
python setup.py bdist_wheel upload
77-
78-
dist: clean ## builds source and wheel package
79-
python setup.py sdist
80-
python setup.py bdist_wheel
81-
ls -l dist
1+
release:
2+
rm dist/*
3+
python setup.py sdist build
4+
python -m twine upload dist/*

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ async def get_response():
118118
loop.run_until_complete(get_response())
119119
```
120120

121+
## Setup User Agent
122+
123+
A UserAgent header can be specified in two ways:
124+
125+
1. By populating the `TRUSTPILOT_USER_AGENT` environment var
126+
2. By creating your own (async/sync)-client instance, or calling `setup` on the `default_session`, and supplying the kwargs `user_agent=foobar`
127+
128+
If no user-agent is given it will autopopulate using the function in `get_user_agent` function in [auth.py](./trustpilot/auth.py)
121129

122130
## CLI
123131

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
collect_ignore.append("trustpilot/async_client.py")
1010

1111
from pytest_readme import setup
12+
1213
setup()

0 commit comments

Comments
 (0)