def SetFromIncompatibleSchema(self): """Sets that we just did an update check and found a new schema version. An incompatible schema version means there are definitely updates available but we can't read the notifications to correctly notify the user. This will install a default notification for the incompatible schema. You must call Save() to persist these changes or use this as a context manager. """ log.debug( 'Incompatible schema found. Activating default notification.') # Nag once a week to update if the schema changed and we don't know what's # going on anymore. notification_spec = schemas.NotificationSpec( id='incompatible', condition=schemas.Condition(None, None, None, None, False), trigger=schemas.Trigger(frequency=604800, command_regex=None), notification=schemas.Notification(None, None, None)) self._data.notifications = [notification_spec] self._CleanUpLastNagTimes() self._data.last_update_check_time = time.time() self._data.last_update_check_revision = 0 # Doesn't matter self._dirty = True
def testNotificationStrings(self): """Ensure that an empty filter will match all OS and Arch.""" n = schemas.Notification(None, None, None) self.assertEqual( n.NotificationMessage(), """ Updates are available for some Cloud SDK components. To install them, please run: $ gcloud components update """) n = schemas.Notification(None, '0.0.0', None) self.assertEqual( n.NotificationMessage(), """ Updates are available for some Cloud SDK components. To install them, please run: $ gcloud components update --version 0.0.0 """) n = schemas.Notification('annotation', '0.0.0', None) self.assertEqual( n.NotificationMessage(), """ annotation Updates are available for some Cloud SDK components. To install them, please run: $ gcloud components update --version 0.0.0 """) n = schemas.Notification('annotation', '0.0.0', 'custom') self.assertEqual(n.NotificationMessage(), """ custom """)