Esempio n. 1
0
 def cleanupIcons(self):
     save = False
     configuration_manager = ConfigurationManager()
     try:
         contacts = configuration_manager.get(['Addressbook', 'Contacts'])
     except Exception:
         return
     for data in contacts.itervalues():
         if 'icon' in data:
             del data['icon']
             save = True
     if save:
         configuration_manager.save()
Esempio n. 2
0
 def cleanupIcons(self):
     save = False
     configuration_manager = ConfigurationManager()
     try:
         contacts = configuration_manager.get(['Addressbook', 'Contacts'])
     except Exception:
         return
     for data in contacts.values():
         if 'icon' in data:
             del data['icon']
             save = True
     if save:
         configuration_manager.save()
Esempio n. 3
0
    def delete(self):
        """Remove the group from the persistent storage."""
        if self.__state__ == 'deleted':
            return
        self.__state__ = 'deleted'

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        configuration.delete(self.__key__)
        notification_center.post_notification('VirtualGroupWasDeleted', sender=self)
        try:
            configuration.save()
        except Exception, e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed', sender=configuration, data=NotificationData(object=self, operation='delete', exception=e))
    def save(self):
        """
        Store the group into persistent storage (local).

        This method will post the VirtualGroupWasCreated and
        VirtualGroupWasActivated notifications on the first save or a
        VirtualGroupDidChange notification on subsequent saves.
        A CFGManagerSaveFailed notification is posted if saving to the
        persistent configuration storage fails.
        """
        if self.__state__ == 'deleted':
            return

        modified_settings = self.get_modified()
        if not modified_settings and self.__state__ != 'new':
            return

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        if self.__state__ == 'new':
            configuration.update(self.__key__, self.__getstate__())
            self.__state__ = 'active'
            modified_data = None
            notification_center.post_notification('VirtualGroupWasActivated',
                                                  sender=self)
            notification_center.post_notification('VirtualGroupWasCreated',
                                                  sender=self)
        else:
            configuration.update(self.__key__, self.__getstate__())
            notification_center.post_notification(
                'VirtualGroupDidChange',
                sender=self,
                data=NotificationData(modified=modified_settings))
            modified_data = modified_settings

        try:
            configuration.save()
        except Exception as e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed',
                                                  sender=configuration,
                                                  data=NotificationData(
                                                      object=self,
                                                      operation='save',
                                                      modified=modified_data,
                                                      exception=e))
    def delete(self):
        """Remove the group from the persistent storage."""
        if self.__state__ == 'deleted':
            return
        self.__state__ = 'deleted'

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        configuration.delete(self.__key__)
        notification_center.post_notification('VirtualGroupWasDeleted',
                                              sender=self)
        try:
            configuration.save()
        except Exception as e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed',
                                                  sender=configuration,
                                                  data=NotificationData(
                                                      object=self,
                                                      operation='delete',
                                                      exception=e))
Esempio n. 6
0
    def save(self):
        """
        Store the group into persistent storage (local).

        This method will post the VirtualGroupWasCreated and
        VirtualGroupWasActivated notifications on the first save or a
        VirtualGroupDidChange notification on subsequent saves.
        A CFGManagerSaveFailed notification is posted if saving to the
        persistent configuration storage fails.
        """
        if self.__state__ == 'deleted':
            return

        modified_settings = self.get_modified()
        if not modified_settings and self.__state__ != 'new':
            return

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        if self.__state__ == 'new':
            configuration.update(self.__key__, self.__getstate__())
            self.__state__ = 'active'
            modified_data = None
            notification_center.post_notification('VirtualGroupWasActivated', sender=self)
            notification_center.post_notification('VirtualGroupWasCreated', sender=self)
        else:
            configuration.update(self.__key__, self.__getstate__())
            notification_center.post_notification('VirtualGroupDidChange', sender=self, data=NotificationData(modified=modified_settings))
            modified_data = modified_settings

        try:
            configuration.save()
        except Exception, e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed', sender=configuration, data=NotificationData(object=self, operation='save', modified=modified_data, exception=e))