def sendHoroscopes(self): """Insert timeline items.""" logging.info('Attempting to push horoscopes.') scopes = horoscopes.getHoroscopes(self) body = horoscopes.createHoroscopeBundle(self, scopes) self.mirror_service.timeline().insert(body=body).execute() return 'Houston, we have horoscopes. Check your Glass Device to confirm.'
def get(self): """Insert a timeline item to all authorized users.""" logging.info('Inserting horoscopes item to all users') users = Credentials.all() total_users = users.count() scopes = horoscopes.getHoroscopes(self) body = horoscopes.createHoroscopeBundle(self, scopes) for user in users: creds = StorageByKeyName( Credentials, user.key().name(), 'credentials').get() mirror_service = util.create_service('mirror', 'v1', creds) mirror_service.timeline().insert(body=body).execute() self._render_template()