@@ -55,39 +55,52 @@ def __init__(self, endpoints, api_path, timeout):
5555 def _shift_endpoint (self , reason ):
5656 old_ep = self ._endpoint
5757 self ._endpoint = next (self ._ep_cycled )
58- self ._l (LOG ).info ("Shifted endpoint from %s to %s for reason: %r" ,
59- old_ep , self ._endpoint , reason )
58+ self ._l (LOG ).info (
59+ "Shifted endpoint from %s to %s for reason: %r" ,
60+ old_ep ,
61+ self ._endpoint ,
62+ reason ,
63+ )
6064
6165 def request (self , path , data , codes = enum .IntEnum ):
6266 url = compat .urljoin (self ._endpoint , path )
6367 try :
64- self ._l (LOG ).debug ("Requesting url %s with timeout %d" ,
65- url , self ._timeout )
66- resp = self ._session .post (url = url ,
67- json = data ,
68- timeout = self ._timeout )
68+ self ._l (LOG ).debug (
69+ "Requesting url %s with timeout %d" , url , self ._timeout
70+ )
71+ resp = self ._session .post (
72+ url = url , json = data , timeout = self ._timeout
73+ )
6974 except req_exc .ConnectionError as e :
7075 self ._shift_endpoint (e )
7176 exc_info = sys .exc_info ()
72- six .reraise (exceptions .ConnectionError ,
73- exceptions .ConnectionError ((self ._endpoint ,),
74- repr (exc_info [1 ])),
75- exc_info [2 ])
77+ six .reraise (
78+ exceptions .ConnectionError ,
79+ exceptions .ConnectionError (
80+ (self ._endpoint ,), repr (exc_info [1 ])
81+ ),
82+ exc_info [2 ],
83+ )
7684 except req_exc .ReadTimeout :
7785 # May happen when master etcd node location is controlled by
7886 # switching IP address in DNS record pointing to the master node.
7987 # We have to reestablish connection to fetch correct IP address.
8088 self ._session .close ()
8189 exc_info = sys .exc_info ()
82- six .reraise (exceptions .ConnectionError ,
83- exceptions .ConnectionError ((self ._endpoint ,),
84- repr (exc_info [1 ])),
85- exc_info [2 ])
90+ six .reraise (
91+ exceptions .ConnectionError ,
92+ exceptions .ConnectionError (
93+ (self ._endpoint ,), repr (exc_info [1 ])
94+ ),
95+ exc_info [2 ],
96+ )
8697 except Exception :
8798 exc_info = sys .exc_info ()
88- six .reraise (exceptions .EtcdException ,
89- exceptions .EtcdException (repr (exc_info [1 ])),
90- exc_info [2 ])
99+ six .reraise (
100+ exceptions .EtcdException ,
101+ exceptions .EtcdException (repr (exc_info [1 ])),
102+ exc_info [2 ],
103+ )
91104 resp .raise_for_status ()
92105 result = resp .json ()
93106 self ._l (LOG ).debug ("Response: %s" , result )
@@ -98,13 +111,16 @@ def request(self, path, data, codes=enum.IntEnum):
98111 try :
99112 code = codes (result ["code" ])
100113 except ValueError :
101- raise exceptions .UnknownResponseCode ("path=%s, data=%r, result=%r"
102- % (path , data , result ))
114+ raise exceptions .UnknownResponseCode (
115+ "path=%s, data=%r, result=%r" % (path , data , result )
116+ )
103117
104118 raise exceptions .UnsuccessfulResponse (code = code , resp = result )
105119
106120
107121def get_session (endpoints , timeout ):
108- return Session (endpoints = endpoints ,
109- api_path = constants .APIVersions .V3BETA .value + "/" ,
110- timeout = timeout )
122+ return Session (
123+ endpoints = endpoints ,
124+ api_path = constants .APIVersions .V3BETA .value + "/" ,
125+ timeout = timeout ,
126+ )
0 commit comments