From 6d8128a36e471246621d801d10a3a5cc0ade18a8 Mon Sep 17 00:00:00 2001 From: Geoffrey Schorkopf Date: Thu, 6 Apr 2017 21:09:42 -0400 Subject: [PATCH] Adds User-Agent header to _fetch * Creates a new file for __version__ --- fastly/__init__.py | 2 ++ fastly/_version.py | 1 + setup.py | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 fastly/_version.py diff --git a/fastly/__init__.py b/fastly/__init__.py index 367c750..9a1d6e4 100755 --- a/fastly/__init__.py +++ b/fastly/__init__.py @@ -27,6 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. from datetime import datetime +from _version import __version__ import httplib2 import json import re @@ -1080,6 +1081,7 @@ def _fetch(self, url, method="GET", body=None, headers={}): hdrs["Fastly-Key"] = self._api_key hdrs["Content-Accept"] = "application/json" + hdrs["User-Agent"] = ("fastly-python-v%s" % __version__) if not hdrs.has_key("Content-Type") and method in ["POST", "PUT"]: hdrs["Content-Type"] = "application/x-www-form-urlencoded" diff --git a/fastly/_version.py b/fastly/_version.py new file mode 100644 index 0000000..8a81504 --- /dev/null +++ b/fastly/_version.py @@ -0,0 +1 @@ +__version__ = '1.0.4' diff --git a/setup.py b/setup.py index 6de2d27..6afc82d 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,13 @@ import os from setuptools import setup +exec(open('fastly/_version.py').read()) def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name = "fastly-python", - version = "1.0.4", + version = __version__, author = "Chris Zacharias", author_email = "chris@imgix.com", description = ("A Python client libary for the Fastly API."),