~ubuntu-branches/ubuntu/lucid/autokey/lucid

« back to all changes in this revision

Viewing changes to src/lib/configmanager.py

  • Committer: Bazaar Package Importer
  • Author(s): Luke Faraone
  • Date: 2009-09-27 15:08:28 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090927150828-6sded0d8od2mqsvp
Tags: 0.60.5-1
* New upstream version (closes: 548531)
  * Change to using pickle instead of cPickle due to a bug in the latter 
  * Bring in changes to common modules needed for GTK version
  * Fix design flaw in pickle error trapping code
  * Fix <enter> not being sent at the end of unicode char entry
  * Fix service crashing when undoing an expansion with backspace
  * Use Phrase instead of Script in some nogui functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
18
 
19
 
import os, os.path, shutil, logging
20
 
import cPickle as pickle
 
19
import os, os.path, shutil, logging, pickle
21
20
import iomediator
22
21
 
23
22
_logger = logging.getLogger("config-manager")
106
105
    try:
107
106
        outFile = open(CONFIG_FILE, "wb")
108
107
        pickle.dump([ConfigManager.SETTINGS, configManager], outFile)
109
 
    except PickleError, pe:
110
 
        shutil.copy(CONFIG_FILE_BACKUP, CONFIG_FILE)
111
 
        _logger.error("Error while saving configuration. Backup has been restored.")
112
 
        raise Exception("Error while saving configuration. Backup has been restored.")
 
108
    except pickle.PickleError, pe:
 
109
        if os.path.exists(CONFIG_FILE_BACKUP):
 
110
            shutil.copy(CONFIG_FILE_BACKUP, CONFIG_FILE)
 
111
        _logger.exception("Error while saving configuration. Backup has been restored (if found).")
 
112
        raise Exception("Error while saving configuration. Backup has been restored (if found).")
 
113
    else:
 
114
        autoKeyApp.init_global_hotkeys(configManager)
 
115
        configManager.app = autoKeyApp
 
116
        _logger.info("Finished persisting configuration - no errors")
113
117
    finally:
114
118
        outFile.close()
115
 
        autoKeyApp.init_global_hotkeys(configManager)
116
 
        configManager.app = autoKeyApp
117
 
        _logger.info("Finished persisting configuration - no errors")
118
119
        
119
120
def upgrade_config_file():
120
121
    """
390
391
        special hotkeys configured from the advanced settings dialog.
391
392
        
392
393
        @param modifiers: modifiers for the hotkey
393
 
        @param abbreviation: the hotkey to check
394
 
        @param targetPhrase: the phrase for which the abbreviation to be used         
 
394
        @param hotKey: the hotkey to check
 
395
        @param targetPhrase: the phrase for which the hotKey to be used        
395
396
        """
396
397
        for item in self.allFolders:
397
398
            if TriggerMode.HOTKEY in item.modes: