Skip to content

Commit 17c28a8

Browse files
authored
Merge pull request #73 from UpCloudLtd/feat/user-agent-header
User agent to header
2 parents abcc5f9 + 6303686 commit 17c28a8

File tree

8 files changed

+36
-14
lines changed

8 files changed

+36
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dist/
1111
docs/html/
1212
.tox
1313
.cache
14+
.vscode/
1415

1516
# pyenv
1617
.python-version

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ matrix:
1515
allow_failures:
1616
- python: "nightly"
1717
include:
18-
- python: "2.6"
18+
- python: "2.7"
1919
dist: trusty
2020
- python: "3.4"
2121
dist: xenial

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ python setup.py install
3131

3232
**Supported versions as of 0.3.3** (offline tests pass with tox):
3333

34-
* python 2.6
34+
* <del>python 2.6</del> removed due to deprecation
3535
* python 2.7
3636
* <del>python 3.2</del> removed due to python2/3 support
3737
* <del>python 3.3</del> removed due to deprecation

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ machine:
77
dependencies:
88
override:
99
- pip install tox tox-pyenv
10-
- pyenv install 2.6.9
11-
- pyenv local 2.6.9 2.7.11 3.3.6 3.4.4 3.5.1
10+
- pyenv install 2.7.11
11+
- pyenv local 2.7.11 3.3.6 3.4.4 3.5.1
1212

1313
test:
1414
override:

setup.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
#!/usr/bin/env python
22

33
from setuptools import setup
4+
import codecs
5+
import os.path
6+
7+
8+
def read(rel_path):
9+
here = os.path.abspath(os.path.dirname(__file__))
10+
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
11+
return fp.read()
12+
13+
14+
def get_version(rel_path):
15+
for line in read(rel_path).splitlines():
16+
if line.startswith('__version__'):
17+
delim = '"' if '"' in line else "'"
18+
return line.split(delim)[1]
19+
else:
20+
raise RuntimeError("Unable to find version string.")
421

522

6-
version = '0.4.6'
723
with open('README.md') as f:
824
long_description = f.read()
925

26+
version = get_version('upcloud_api/__init__.py')
1027
setup(
1128
name='upcloud-api',
1229
version=version,
@@ -20,7 +37,7 @@
2037
packages=['upcloud_api', 'upcloud_api.cloud_manager'],
2138
download_url='https://github.com/UpCloudLtd/upcloud-python-api/archive/%s.tar.gz' % version,
2239
license='MIT',
23-
python_requires='>=2.6,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
40+
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
2441
install_requires=[
2542
'requests>=2.6.0',
2643
'six>=1.9.0'

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Tox (http://tox.testrun.org/) is a tool for running tests
1+
# Tox (https://tox.readthedocs.io/) is a tool for running tests
22
# in multiple virtualenvs. This configuration file will run the
33
# test suite on all supported python versions. To use it, "pip install tox"
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py26, py27, py34, py35, py36, py37, py38, pypy3
7+
envlist = py27, py34, py35, py36, py37, py38, pypy3
88
skip_missing_interpreters = True
99

1010
[testenv]

upcloud_api/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
from __future__ import unicode_literals
88
from __future__ import absolute_import
99

10-
__version__ = '0.3.9'
10+
11+
__version__ = '0.4.6'
1112
__author__ = 'Elias Nygren'
12-
__author_email__ = 'elias.nygren@upcloud.com'
13-
__license__ = 'MIT'
14-
__copyright__ = 'Copyright (c) 2015 Elias Nygren'
13+
__author_email__ = 'elias.nygren@upcloud.com'
14+
__maintainer__ = 'UpCloud'
15+
__maintainer_email__ = 'hello@upcloud.com'
16+
__license__ = 'MIT'
17+
__copyright__ = 'Copyright (c) 2015 UpCloud'
1518

1619
from upcloud_api.upcloud_resource import UpCloudResource
1720
from upcloud_api.errors import UpCloudClientError, UpCloudAPIError

upcloud_api/cloud_manager/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import requests
55

6-
from upcloud_api import UpCloudAPIError
6+
from upcloud_api import UpCloudAPIError, __version__
77

88

99
class BaseAPI(object):
@@ -29,7 +29,8 @@ def request(self, method, endpoint, body=None, timeout=-1, request_to_api=True):
2929

3030
url = 'https://api.upcloud.com/' + self.api_v + endpoint if request_to_api else endpoint
3131
headers = {
32-
'Authorization': self.token
32+
'Authorization': self.token,
33+
'User-Agent': 'upcloud-python-api/{}'.format(__version__)
3334
}
3435

3536
headers['Content-Type'] = 'application/json' if request_to_api else 'application/octet-stream'

0 commit comments

Comments
 (0)