diff --git a/src/config.py b/src/config.py index 996a4fa..1891a7d 100644 --- a/src/config.py +++ b/src/config.py @@ -6,7 +6,7 @@ SCOPE = 'https://www.googleapis.com/auth/drive.readonly' REDIRECT_URI = 'http://127.0.0.1:1337' -AUTH_URL = 'https://accounts.google.com/o/oauth2/auth?scope=%s&redirect_uri=%s&response_type=code&client_id=%s&access_type=offline&approval_prompt=force' % (SCOPE, REDIRECT_URI, CLIENT_ID) +AUTH_URL = 'https://accounts.google.com/o/oauth2/auth?scope=%(scope)s&redirect_uri=%(redirect_uri)s&response_type=code&client_id=%(client_id)s&access_type=offline&approval_prompt=force' % {'scope' : SCOPE, 'redirect_uri' : REDIRECT_URI, 'client_id' : CLIENT_ID} TOKEN_URL = 'https://www.googleapis.com/oauth2/v3/token' FILES_URL = 'https://www.googleapis.com/drive/v2/files?fields=items' diff --git a/src/logging.log b/src/logging.log new file mode 100644 index 0000000..668c3cd --- /dev/null +++ b/src/logging.log @@ -0,0 +1,13 @@ +INFO:root:Configuring server +INFO:root:GET request received +INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): www.googleapis.com +DEBUG:workflow:Password exists : com.drive.azai91:drive_access_token +DEBUG:workflow:Got password : com.drive.azai91:drive_access_token +DEBUG:workflow:Deleted password : com.drive.azai91:drive_access_token +DEBUG:workflow:save_password : com.drive.azai91:drive_access_token +DEBUG:workflow:Password exists : com.drive.azai91:drive_refresh_token +DEBUG:workflow:Got password : com.drive.azai91:drive_refresh_token +DEBUG:workflow:Deleted password : com.drive.azai91:drive_refresh_token +DEBUG:workflow:save_password : com.drive.azai91:drive_refresh_token +INFO:root:Account Saved +INFO:root:Server started on port 1337 diff --git a/src/server.py b/src/server.py index b719f0b..ed034c9 100644 --- a/src/server.py +++ b/src/server.py @@ -4,13 +4,20 @@ import urlparse from time import sleep import subprocess +import logging +import sys +logging.basicConfig(filename='logging.log',level=logging.INFO) +logging.info('Configuring server') class HandlerClass(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(s): + logging.info('GET request received') try: code = urlparse.urlparse(s.path)[4].split('=')[1] user_credentials = Drive.exchange_tokens(code) subprocess.call(['python','./drive_refresh.py']) + sys.stdout.write('Account Saved') + logging.info('Account Saved') s.wfile.write('Your code has been saved in Alfred') except: s.wfile.write('Error with setting code') @@ -24,3 +31,4 @@ def do_GET(s): httpd = ServerClass(server_address, HandlerClass) httpd.timeout = 20 httpd.handle_request() +logging.info('Server started on port 1337')