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 testTriggerMatch(self): t = schemas.Trigger(0, None) self.assertTrue(t.Matches(0, 'gcloud.foo')) t = schemas.Trigger(100, None) self.assertTrue(t.Matches(0)) t = schemas.Trigger(10000, None) self.assertFalse(t.Matches(time.time(), 'gcloud.foo')) t = schemas.Trigger(100, 'gcloud.compute.instances') self.assertFalse(t.Matches(0, 'gcloud.foo')) t = schemas.Trigger(100, r'gcloud\.compute\..*') self.assertTrue(t.Matches(0, 'gcloud.compute.instances*')) self.assertFalse(t.Matches(0, None))