chiark / gitweb /
Fix the loading of the old preferences file. Look in more locations, move the log...
authordaid <daid303@gmail.com>
Thu, 30 Oct 2014 07:30:25 +0000 (08:30 +0100)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Wed, 14 Jan 2015 17:09:56 +0000 (12:09 -0500)
Cura/gui/app.py
Cura/util/profile.py

index a0bfd57a6f0f867106d7d4158d34c16a660afb8c..94d11cc04be5793cfdefeec5111a5643ed56fe6b 100644 (file)
@@ -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'))
 
index 28970aea71e250f992bc93818717b8bb923e4e4e..4ffa7f45e8bf2b7454ff29d8d518560be48647e5 100644 (file)
@@ -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