#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.\r
import __init__\r
\r
-import os, traceback, math, re, zlib, base64, time, sys\r
+import os, traceback, math, re, zlib, base64, time, sys, platform \r
if sys.version_info[0] < 3:\r
import ConfigParser\r
else:\r
import configparser as ConfigParser\r
+
+from util import version
\r
#########################################################\r
## Default settings when none are found.\r
\r
## Profile functions\r
def getDefaultProfilePath():\r
- basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
- #If we have a frozen python install, we need to step out of the library.zip\r
- if hasattr(sys, 'frozen'):\r
- basePath = os.path.normpath(os.path.join(basePath, ".."))\r
- return os.path.normpath(os.path.join(basePath, "current_profile.ini"))\r
+ if platform.system() == "Windows":
+ basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
+ #If we have a frozen python install, we need to step out of the library.zip\r
+ if hasattr(sys, 'frozen'):\r
+ basePath = os.path.normpath(os.path.join(basePath, ".."))
+ else:
+ basePath = os.path.expanduser('~/.cura/%s' % version.getVersion(False))
+ if not os.path.isdir(basePath):
+ os.makedirs(basePath)\r
+ return os.path.join(basePath, 'current_profile.ini')\r
\r
def loadGlobalProfile(filename):\r
#Read a configuration file as global config\r
globalPreferenceParser = None\r
\r
def getPreferencePath():\r
- basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
- #If we have a frozen python install, we need to step out of the library.zip\r
- if hasattr(sys, 'frozen'):\r
- basePath = os.path.normpath(os.path.join(basePath, ".."))\r
- return os.path.normpath(os.path.join(basePath, "preferences.ini"))\r
+ if platform.system() == "Windows":
+ basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
+ #If we have a frozen python install, we need to step out of the library.zip\r
+ if hasattr(sys, 'frozen'):\r
+ basePath = os.path.normpath(os.path.join(basePath, ".."))
+ else:
+ basePath = os.path.expanduser('~/.cura/%s' % version.getVersion(False))
+ if not os.path.isdir(basePath):
+ os.makedirs(basePath)\r
+ return os.path.join(basePath, 'preferences.ini')\r
\r
def getPreferenceFloat(name):\r
try:\r