Wrap os.makedirs in a try-except block.

pull/41/head
Christian Jacobs 2015-11-29 22:34:48 +00:00
rodzic a115e0f27d
commit 7c173206e1
1 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -54,8 +54,11 @@ class PyQSO(Gtk.Window):
Gtk.Window.__init__(self, title="PyQSO")
# Check that the directory for holding PyQSO configuration files exists. If it doesn't, create it now.
if not os.path.exists(os.path.expanduser('~/.config/pyqso')):
os.makedirs(os.path.expanduser('~/.config/pyqso'))
try:
os.makedirs(os.path.expanduser('~/.config/pyqso'), exist_ok=True)
except Exception as e:
logging.error("An error occurred whilst creating a directory for PyQSO configuration files. Try creating the directory '~/.config/pyqso' manually.")
logging.exception(e)
# Get any application-specific preferences from the configuration file
config = configparser.ConfigParser()