From f698f9607837b6942a514dabcea7588f5fe25ee8 Mon Sep 17 00:00:00 2001 From: Greg Pflaum Date: Sun, 31 Jan 2021 08:47:06 -0500 Subject: [PATCH] Make messages match the output of the ruby example --- python-pygithub/lib/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python-pygithub/lib/__init__.py b/python-pygithub/lib/__init__.py index 00a6705..e28b5f7 100644 --- a/python-pygithub/lib/__init__.py +++ b/python-pygithub/lib/__init__.py @@ -12,10 +12,17 @@ def __init__(self, meta): @staticmethod def auth(func): def wrapper(self, *args, **kwargs): - self.github_client() if not self.gh or self.is_expired() else None + if not self.gh or self.is_expired(): + print("- TOKEN STATUS: EXPIRED") + self.github_client() + print("- TOKEN STATUS: REFRESHED") + print("- TOKEN STATUS: CURRENT") + print(f"- TOKEN EXPIRY: {self.expires_at.strftime('%Y-%m-%d %H:%M:%S')}") + return func(self, *args, **kwargs) + return wrapper - + def is_expired(self): return datetime.now().timestamp() + 60 >= self.expires_at.timestamp()