diff --git a/src/pcloud/oauth2.py b/src/pcloud/oauth2.py index bb44510..e97aa7c 100644 --- a/src/pcloud/oauth2.py +++ b/src/pcloud/oauth2.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import logging import _thread import time @@ -8,6 +9,9 @@ from urllib.parse import urlparse from webbrowser import open_new +log = logging.getLogger("pcloud") +log.setLevel(logging.INFO) + PORT = 65432 REDIRECT_URL = f"http://localhost:{PORT}/" @@ -63,10 +67,12 @@ def get_access_token(self): def start_server(): http_server.handle_request() + log.info(f"Start token server {PORT}") _thread.start_new_thread(start_server, ()) self.open_browser() while not (http_server.access_token and http_server.pc_hostname): time.sleep(1) self.close_browser() http_server.server_close() + log.info(f"Teardown token server {PORT}") return http_server.access_token, http_server.pc_hostname