Skip to content

Commit

Permalink
Add timestamps, remove indent in HTTP debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrance committed May 26, 2016
1 parent 34309a7 commit a7e768f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions skpy/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ def externalCall(cls, method, url, codes=(200, 201, 204, 207), **kwargs):
.SkypeApiException: if a successful status code is not received
"""
if os.getenv("SKPY_DEBUG_HTTP"):
print("=> {0} {1}".format(method, url))
print(" {0}".format(pformat(kwargs)))
print("<= [{0}] {1} {2}".format(datetime.now().strftime("%d/%m %H:%M:%S"), method, url))
print(pformat(kwargs))
resp = cls.extSess.request(method, url, **kwargs)
if os.getenv("SKPY_DEBUG_HTTP"):
print("<= {0}".format(resp.status_code))
print("=> [{0}] {1}".format(datetime.now().strftime("%d/%m %H:%M:%S"), resp.status_code))
try:
print(" {0}".format(pformat(resp.json())))
print(pformat(resp.json()))
except:
print(" {0}".format(resp.text))
print(resp.text)
if resp.status_code not in codes:
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
return resp
Expand Down Expand Up @@ -194,15 +194,15 @@ def __call__(self, method, url, codes=(200, 201, 204, 207), auth=None, headers=N
elif auth == self.Auth.RegToken:
headers["RegistrationToken"] = self.tokens["reg"]
if os.getenv("SKPY_DEBUG_HTTP"):
print("=> {0} {1}".format(method, url))
print(" {0}".format(pformat(kwargs).replace("\n", "\n ")))
print("<= [{0}] {1} {2}".format(datetime.now().strftime("%d/%m %H:%M:%S"), method, url))
print(pformat(kwargs))
resp = self.sess.request(method, url, headers=headers, **kwargs)
if os.getenv("SKPY_DEBUG_HTTP"):
print("<= {0}".format(resp.status_code))
print("=> [{0}] {1}".format(datetime.now().strftime("%d/%m %H:%M:%S"), resp.status_code))
try:
print(" {0}".format(pformat(resp.json()).replace("\n", "\n ")))
print(pformat(resp.json()))
except:
print(" {0}".format(resp.text.replace("\n", "\n ")))
print(resp.text)
if resp.status_code not in codes:
if resp.status_code == 429:
raise SkypeAuthException("Auth rate limit exceeded", resp)
Expand Down

0 comments on commit a7e768f

Please sign in to comment.