From: daid Date: Thu, 30 Oct 2014 07:30:25 +0000 (+0100) Subject: Fix the loading of the old preferences file. Look in more locations, move the log... X-Git-Tag: lulzbot-14.12~46 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f40bcf98030c7b33925414f1978d2aeda6ab4bea;p=cura.git Fix the loading of the old preferences file. Look in more locations, move the log file to the user directory. --- diff --git a/Cura/gui/app.py b/Cura/gui/app.py index a0bfd57a..94d11cc0 100644 --- a/Cura/gui/app.py +++ b/Cura/gui/app.py @@ -8,16 +8,17 @@ import glob import warnings try: - #Only try to import the _core to save import time - import wx._core + #Only try to import the _core to save import time + import wx._core except ImportError: - import wx + import wx class CuraApp(wx.App): def __init__(self, files): if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ: - super(CuraApp, self).__init__(redirect=True, filename='output.txt') + from Cura.util import profile + super(CuraApp, self).__init__(redirect=True, filename=os.path.join(profile.getBasePath(), 'output_log.txt')) else: super(CuraApp, self).__init__(redirect=False) @@ -110,21 +111,21 @@ class CuraApp(wx.App): if profile.getMachineSetting('machine_type') == 'unknown': try: otherCuraInstalls = profile.getAlternativeBasePaths() - otherCuraInstalls.sort() - if len(otherCuraInstalls) > 0: - profile.loadPreferences(os.path.join(otherCuraInstalls[-1], 'preferences.ini')) - profile.loadProfile(os.path.join(otherCuraInstalls[-1], 'current_profile.ini')) + for path in otherCuraInstalls[::-1]: + try: + print 'Loading old settings from %s' % (path) + profile.loadPreferences(os.path.join(path, 'preferences.ini')) + profile.loadProfile(os.path.join(path, 'current_profile.ini')) + break + except: + import traceback + print traceback.print_exc() except: import traceback print traceback.print_exc() #If we haven't run it before, run the configuration wizard. if profile.getMachineSetting('machine_type') == 'unknown': - otherCuraInstalls = profile.getAlternativeBasePaths() - otherCuraInstalls.sort() - if len(otherCuraInstalls) > 0: - profile.loadPreferences(os.path.join(otherCuraInstalls[-1], 'preferences.ini')) - profile.loadProfile(os.path.join(otherCuraInstalls[-1], 'current_profile.ini')) #Check if we need to copy our examples exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'Rocktopus.stl')) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 28970aea..4ffa7f45 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -623,19 +623,32 @@ def getAlternativeBasePaths(): path = os.path.join(basePath, subPath, 'Cura') if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')) and path != getBasePath(): paths.append(path) - - #Check the old base path, which was in the application directory. - oldBasePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) - basePath = os.path.normpath(os.path.join(oldBasePath, "..")) - for subPath in os.listdir(basePath): - path = os.path.join(basePath, subPath) - if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')) and path != oldBasePath: - paths.append(path) - path = os.path.join(basePath, subPath, 'Cura') - if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')) and path != oldBasePath: - paths.append(path) + paths.sort() + + if sys.platform.startswith('win'): + extra_list = [] + #Check the old base path, which was in the application directory. + basePath = "C:\\program files (x86)\\" + for subPath in os.listdir(basePath): + path = os.path.join(basePath, subPath) + if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')): + extra_list.append(path) + path = os.path.join(basePath, subPath, 'Cura') + if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')): + extra_list.append(path) + basePath = "C:\\program files\\" + for subPath in os.listdir(basePath): + path = os.path.join(basePath, subPath) + if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')): + extra_list.append(path) + path = os.path.join(basePath, subPath, 'Cura') + if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'preferences.ini')): + extra_list.append(path) + extra_list.sort() + paths = extra_list + paths except: - pass + import traceback + print traceback.print_exc() return paths