Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pkg details to user agent #82

Closed
wants to merge 2 commits into from

Conversation

JohnLZeller
Copy link

In response to #80.

This modifies the default User-Agent to include package details: python closeio v{VERSION} {DEFAULT}

Also breaks out the version constant into its' own version file. This helps to reduce the change of inconsistent versions, while also making it easy to add the seudo-standard __version__ attribute :)

Testing

Setup a simple server script to dump headers when making calls with the client. Then loaded the modified closeio_api and the output of the dump confirms this is working.

----- Request Start ----->

/lead/
Host: localhost:8000
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python closeio v0.5 python-requests/2.11.1
Content-Type: application/json
X-TZ-Offset: -7
Content-Length: 20
Authorization: Basic abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx

{"name": "New Lead"}
<----- Request End -----

127.0.0.1 - - [13/Mar/2017 17:25:57] "POST /lead/ HTTP/1.1" 200 -

@philfreo
Copy link
Member

philfreo commented Mar 14, 2017

Thanks for the contribution! Did you accidentally forget to include _version.py in this PR?

@JohnLZeller
Copy link
Author

I literally just noticed that actually :) You're quick on the draw! (added)

@@ -1,11 +1,14 @@
from setuptools import setup

# Version comes directly from source w/o importing
exec(open('closeio_api/_version.py').read())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't use exec, and the current directory may not necessarily be the one that contains closeio_api. Is there any convention on how to do this best?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason we can't do something like from _version import __version__?

@eengoron
Copy link
Contributor

Closing this via #104

@eengoron eengoron closed this Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants