From 8b9dbec188f92bcf632de25ef4990f06f7c13732 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 30 Jun 2015 18:06:58 +0200 Subject: [PATCH] Reset configuration files on start if old config files were found --- cura/CuraApplication.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 41e02a3cc1..8b67ec5467 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -41,7 +41,9 @@ from PyQt5.QtGui import QColor, QIcon import platform import sys +import os import os.path +import configparser import numpy numpy.seterr(all="ignore") @@ -51,6 +53,23 @@ class CuraApplication(QtApplication): if not hasattr(sys, "frozen"): Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) + # Reset the configuration files if they exist on the machine, only for 15.05.xx releases + try: + Resources.ApplicationIdentifier = "cura" + parser = configparser.ConfigParser() + parser.read(Resources.getStoragePath(Resources.PreferencesLocation, "cura.cfg")) + except FileNotFoundError: + pass + else: + if parser["general"]["version"] != "2": + Logger.log("i", "Found old settings files, removing them") + + os.remove(Resources.getStoragePath(Resources.PreferencesLocation, "cura.cfg")) + + path = Resources.getStorageLocation(Resources.SettingsLocation) + for file in os.listdir(path): + os.remove(os.path.join(path, file)) + super().__init__(name = "cura", version = "15.06.00") self.setWindowIcon(QIcon(Resources.getPath(Resources.ImagesLocation, "cura-icon.png")))