diff --git a/platypush/backend/http/static/css/widgets/music.css b/platypush/backend/http/static/css/widgets/music.css index 3ed8d1e9..04f789a6 100644 --- a/platypush/backend/http/static/css/widgets/music.css +++ b/platypush/backend/http/static/css/widgets/music.css @@ -47,3 +47,7 @@ letter-spacing: 1px; } +.no-track-info { + font-size: 20px; +} + diff --git a/platypush/plugins/google/calendar.py b/platypush/plugins/google/calendar.py new file mode 100644 index 00000000..fa38bae7 --- /dev/null +++ b/platypush/plugins/google/calendar.py @@ -0,0 +1,40 @@ +import base64 +import datetime +import httplib2 +import os + +from apiclient import discovery + +from platypush.message.response import Response +from platypush.plugins.google import GooglePlugin + + +class GoogleCalendarPlugin(GooglePlugin): + scopes = ['https://www.googleapis.com/auth/calendar.readonly'] + + def __init__(self, *args, **kwargs): + super().__init__(scopes=self.scopes, *args, **kwargs) + + + def get_upcoming_events(self, max_results=10): + now = datetime.datetime.utcnow().isoformat() + 'Z' + service = self._get_service() + result = service.events().list(calendarId='primary', timeMin=now, + maxResults=10, singleEvents=True, + orderBy='startTime').execute() + + events = result.get('items', []) + return Response(output=events) + + + def _get_service(self, scope=None): + if scope is None: + scope = self.scopes[0] + + credentials = self.credentials[scope] + http = credentials.authorize(httplib2.Http()) + return discovery.build('calendar', 'v3', http=http, cache_discovery=False) + + +# vim:sw=4:ts=4:et: + diff --git a/platypush/plugins/google/credentials.py b/platypush/plugins/google/credentials.py index 8086d195..1c1097c5 100644 --- a/platypush/plugins/google/credentials.py +++ b/platypush/plugins/google/credentials.py @@ -24,14 +24,14 @@ def get_credentials_filename(scope): def get_credentials(scope): credentials_file = get_credentials_filename(scope) if not os.path.exists(credentials_file): - raise RuntimeError('Credentials file {} not found. Generate it through:\n' + - '\tpython -m platypush.google.credentials "{}"' + + raise RuntimeError(('Credentials file {} not found. Generate it through:\n' + + '\tpython -m platypush.plugins.google.credentials "{}" ' + '\n' + '\t\t[--auth_host_name AUTH_HOST_NAME]\n' + '\t\t[--noauth_local_webserver]\n' + '\t\t[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]\n' + - '\t\t[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]\n'. - format(credentials_file, scope_name)) + '\t\t[--logging_level [DEBUG,INFO,WARNING,ERROR,CRITICAL]]\n'). + format(credentials_file, scope)) store = Storage(credentials_file) credentials = store.get()