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)
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', 'UltimakerRobot_support.stl'))
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