File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1616
1717from pkg_resources import get_distribution
1818
19+ import httplib2
20+ import socket
21+
22+ __environ__ = ''
23+ try :
24+ from google import appengine
25+ __environ__ = '-GAE' # pragma: NO COVER
26+ except ImportError :
27+ pass
28+
29+
1930__version__ = get_distribution ('gcloud' ).version
31+
32+
33+ if __environ__ == '' :
34+ RESPONSE = None
35+ try :
36+ RESPONSE , _ = httplib2 .Http (timeout = 0.1 ).request (
37+ uri = 'http://169.254.169.254/computeMetadata/v1/project/project-id' ,
38+ headers = {'Metadata-Flavor' : 'Google' })
39+
40+ if RESPONSE ['status' ] == '200' : # pragma: NO COVER
41+ __environ__ = '-GCE' # pragma: NO COVER
42+ except socket .timeout :
43+ pass
44+ finally :
45+ del RESPONSE
46+ else : # pragma: NO COVER
47+ pass # pragma: NO COVER
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class Connection(object):
3232 _EMPTY = object ()
3333 """A pointer to represent an empty value for default arguments."""
3434
35- USER_AGENT = "gcloud-python/{0}" .format (gcloud .__version__ )
35+ USER_AGENT = "gcloud-python/{0}{1}" .format (gcloud .__version__ ,
36+ gcloud .__environ__ )
3637 """The user agent for gcloud-python requests."""
3738
3839 def __init__ (self , credentials = None ):
You can’t perform that action at this time.
0 commit comments