From 375d272ee8f43d6c942469b8367bfd1a6c4dfe05 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 14 Jan 2010 22:58:41 +0000 Subject: [PATCH] make the config directory if it doesn't exist, and don't explode if we can't write it --- terminatorlib/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index abcff535..6d714b23 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -433,7 +433,13 @@ class ConfigBase(Borg): dbg('ConfigBase::save: Processing plugin: %s' % plugin) parser['plugins'][plugin] = self.plugins[plugin] - parser.write(open(os.path.join(get_config_dir(), 'epic-config'), 'w')) + config_dir = get_config_dir() + if not os.isdir(config_dir): + os.makedirs(config_dir) + try: + parser.write(open(os.path.join(config_dir, 'epic-config'), 'w')) + except Exception, ex: + err('ConfigBase::save: Unable to save config: %s' % ex) def get_item(self, key, profile='default', plugin=None): """Look up a configuration item"""