diff options
author | mathieui <mathieui@mathieui.net> | 2013-06-09 03:45:10 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-06-09 03:45:10 +0200 |
commit | 9eaffe1369f2be177576402f20edcd114a1eaa9d (patch) | |
tree | 7230d1ac073f3327964088395cec0f900fbf2710 | |
parent | 9b8ed569bb202da1c1a7e88eff32152730b3f322 (diff) | |
download | poezio-9eaffe1369f2be177576402f20edcd114a1eaa9d.tar.gz poezio-9eaffe1369f2be177576402f20edcd114a1eaa9d.tar.bz2 poezio-9eaffe1369f2be177576402f20edcd114a1eaa9d.tar.xz poezio-9eaffe1369f2be177576402f20edcd114a1eaa9d.zip |
Fix the os.makedirs calls so that they don’t traceback for nothing
-rw-r--r-- | src/config.py | 2 | ||||
-rw-r--r-- | src/logger.py | 7 | ||||
-rw-r--r-- | src/plugin_manager.py | 4 | ||||
-rw-r--r-- | src/theming.py | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/src/config.py b/src/config.py index 3e6c24f0..695362e5 100644 --- a/src/config.py +++ b/src/config.py @@ -243,7 +243,7 @@ if not CONFIG_HOME: CONFIG_PATH = path.join(CONFIG_HOME, 'poezio') try: - makedirs(CONFIG_PATH) + makedirs(CONFIG_PATH, exist_ok=True) except OSError: pass diff --git a/src/logger.py b/src/logger.py index 7df44a29..ba848593 100644 --- a/src/logger.py +++ b/src/logger.py @@ -56,14 +56,17 @@ class Logger(object): return directory = os.path.join(DATA_HOME, 'logs') try: - makedirs(directory) + makedirs(directory, exist_ok=True) except OSError: - pass + import traceback + log.debug('Cannot create log directory "%s":\n%s', directory, traceback.format_exc()) try: fd = open(os.path.join(directory, room), 'a') self.fds[room] = fd return fd except IOError: + import traceback + log.debug('Cannot open logfile %s:\n%s', room, traceback.format_exc()) return def get_logs(self, jid, nb=10): diff --git a/src/plugin_manager.py b/src/plugin_manager.py index 9e253f97..74d5a2d3 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -38,14 +38,14 @@ if not plugins_conf_dir: plugins_conf_dir = os.path.expanduser(plugins_conf_dir) try: - os.makedirs(plugins_dir) + os.makedirs(plugins_dir, exist_ok=True) except OSError: pass else: load_path.append(plugins_dir) try: - os.makedirs(plugins_conf_dir) + os.makedirs(plugins_conf_dir, exist_ok=True) except OSError: pass diff --git a/src/theming.py b/src/theming.py index c999ef2c..c26a4733 100644 --- a/src/theming.py +++ b/src/theming.py @@ -372,7 +372,7 @@ def reload_theme(): 'poezio', 'themes') themes_dir = os.path.expanduser(themes_dir) try: - os.makedirs(themes_dir) + os.makedirs(themes_dir, exist_ok=True) except OSError: pass theme_name = config.get('theme', 'default') |