def get_scrap_prefix(self): prefix = self.app.preferences['saving.scrap_prefix'] prefix = helpers.expanduser_unicode(prefix.decode('utf-8')) prefix = os.path.abspath(prefix) if os.path.isdir(prefix): if not prefix.endswith(os.path.sep): prefix += os.path.sep return prefix
def get_scrap_prefix(self): prefix = self.app.preferences["saving.scrap_prefix"] prefix = helpers.expanduser_unicode(prefix.decode("utf-8")) prefix = os.path.abspath(prefix) if os.path.isdir(prefix): if not prefix.endswith(os.path.sep): prefix += os.path.sep return prefix
def get_gimp_prefix(self): from lib import helpers homepath = helpers.expanduser_unicode(u'~') if sys.platform == 'win32': # using patched win32 glib using correct CSIDL_LOCAL_APPDATA import glib confpath = os.path.join(glib.get_user_config_dir().decode('utf-8'),'gimp-2.6') elif homepath == '~': confpath = os.path.join(prefix, 'UserData') else: confpath = os.path.join(homepath, '.gimp-2.6') return confpath
def get_gimp_prefix(self): from lib import helpers homepath = helpers.expanduser_unicode(u"~") if sys.platform == "win32": # using patched win32 glib using correct CSIDL_LOCAL_APPDATA import glib confpath = os.path.join(glib.get_user_config_dir().decode("utf-8"), "gimp-2.6") elif homepath == "~": confpath = os.path.join(prefix, "UserData") else: confpath = os.path.join(homepath, ".gimp-2.6") return confpath
def get_paths(): join = os.path.join # Convert sys.argv to a list of unicode objects # (actually converting sys.argv confuses gtk, thus we add a new variable) if sys.platform == 'win32': sys.argv_unicode = win32_unicode_argv() else: sys.argv_unicode = [s.decode(sys.getfilesystemencoding()) for s in sys.argv] # Script and its location, in canonical absolute form scriptfile = os.path.abspath(os.path.normpath(sys.argv_unicode[0])) scriptdir = os.path.dirname(scriptfile) assert isinstance(scriptfile, unicode) assert isinstance(scriptdir, unicode) # Determine $prefix dir_install = scriptdir if os.path.basename(dir_install) == 'bin': # This is a normal POSIX installation. prefix = os.path.dirname(dir_install) assert isinstance(prefix, unicode) libpath = join(prefix, 'share', 'mypaint') libpath_compiled = join(prefix, 'lib', 'mypaint') # or lib64? sys.path.insert(0, libpath) sys.path.insert(0, libpath_compiled) localepath = join(prefix, 'share', 'locale') localepath_brushlib = localepath extradata = join(prefix, 'share') elif sys.platform == 'win32': prefix=None # this is py2exe point of view, all executables in root of installdir libpath = os.path.realpath(scriptdir) sys.path.insert(0, libpath) localepath = join(libpath, 'share', 'locale') localepath_brushlib = localepath extradata = join(libpath, 'share') else: # Not installed: run out of the source tree. prefix = None libpath = u'.' extradata = u'desktop' localepath = 'po' localepath_brushlib = 'brushlib/po' assert isinstance(libpath, unicode) try: # just for a nice error message from lib import mypaintlib except ImportError: print print "We are not correctly installed or compiled!" print 'script: "%s"' % sys.argv[0] if prefix: print 'deduced prefix: "%s"' % prefix print 'lib_shared: "%s"' % libpath print 'lib_compiled: "%s"' % libpath_compiled print raise # Ensure that pyGTK compatibility is setup before anything else from gui import pygtkcompat datapath = libpath if not os.path.isdir(join(datapath, 'brushes')): print 'Default brush collection not found! It should have been here:' print datapath raise sys.exit(1) # Old style config file and user data locations. # Return None if using XDG will be correct. if sys.platform == 'win32': old_confpath = None else: from lib import helpers homepath = helpers.expanduser_unicode(u'~') old_confpath = join(homepath, '.mypaint/') if old_confpath: if not os.path.isdir(old_confpath): old_confpath = None else: print "INFO: Found old-style configuration in %s." % old_confpath print "INFO: This can be migrated to $XDG_CONFIG_HOME and " \ "$XDG_DATA_HOME if you wish." print "INFO: See the XDG Base Directory Specification for info." assert isinstance(old_confpath, unicode) or old_confpath is None assert isinstance(datapath, unicode) assert isinstance(extradata, unicode) return datapath, extradata, old_confpath, localepath, localepath_brushlib
def get_paths(): join = os.path.join lib_shared='share/mypaint/' # note: some distros use lib64 instead, they have to edit this... lib_compiled='lib/mypaint/' # convert sys.argv to a list of unicode objects # (actually convertig sys.argv confuses gtk, thus we add a new variable) if sys.platform == 'win32': sys.argv_unicode = win32_unicode_argv() else: sys.argv_unicode = [s.decode(sys.getfilesystemencoding()) for s in sys.argv] scriptdir=os.path.dirname(sys.argv_unicode[0]) # this script is installed as $prefix/bin. We just need $prefix to continue. #pwd=os.getcwd() # why???? #dir_install=os.path.normpath(join(pwd,scriptdir)) # why???? dir_install=scriptdir # same, except maybe if scriptdir is relative... if os.path.basename(dir_install) == 'bin': prefix=os.path.dirname(dir_install) assert isinstance(prefix, unicode) libpath=join(prefix, lib_shared) libpath_compiled = join(prefix, lib_compiled) sys.path.insert(0, libpath) sys.path.insert(0, libpath_compiled) localepath = join(prefix, 'share/locale') localepath_brushlib = localepath extradata = join(prefix, 'share') elif sys.platform == 'win32': prefix=None # this is py2exe point of view, all executables in root of installdir # all path must be normalized to absolute path libpath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv_unicode[0]))) sys.path.insert(0, libpath) localepath = join(libpath, 'share/locale') localepath_brushlib = localepath extradata = join(libpath, 'share') else: # we are not installed prefix = None libpath = u'.' extradata = u'desktop' localepath = 'po' localepath_brushlib = 'brushlib/po' assert isinstance(libpath, unicode) try: # just for a nice error message from lib import mypaintlib except ImportError: print print "We are not correctly installed or compiled!" print 'script: "%s"' % sys.argv[0] if prefix: print 'deduced prefix: "%s"' % prefix print 'lib_shared: "%s"' % libpath print 'lib_compiled: "%s"' % libpath_compiled print raise # Ensure that pyGTK compatibility is setup before anything else from gui import pygtkcompat datapath = libpath if not os.path.isdir(join(datapath, 'brushes')): print 'Default brush collection not found! It should have been here:' print datapath raise sys.exit(1) from lib import helpers homepath = helpers.expanduser_unicode(u'~') if sys.platform == 'win32': # using patched win32 glib using correct CSIDL_LOCAL_APPDATA import glib confpath = os.path.join(glib.get_user_config_dir().decode('utf-8'),'mypaint') elif homepath == '~': confpath = join(prefix, 'UserData') else: confpath = join(homepath, '.mypaint/') assert isinstance(datapath, unicode) assert isinstance(confpath, unicode) assert isinstance(extradata, unicode) return datapath, extradata, confpath, localepath, localepath_brushlib
def get_paths(): join = os.path.join # Convert sys.argv to a list of unicode objects # (actually converting sys.argv confuses gtk, thus we add a new variable) if sys.platform == 'win32': sys.argv_unicode = win32_unicode_argv() else: sys.argv_unicode = [ s.decode(sys.getfilesystemencoding()) for s in sys.argv ] # Script and its location, in canonical absolute form scriptfile = os.path.abspath(os.path.normpath(sys.argv_unicode[0])) scriptdir = os.path.dirname(scriptfile) assert isinstance(scriptfile, unicode) assert isinstance(scriptdir, unicode) # Determine $prefix dir_install = scriptdir if os.path.basename(dir_install) == 'bin': # This is a normal POSIX installation. prefix = os.path.dirname(dir_install) assert isinstance(prefix, unicode) libpath = join(prefix, 'share', 'mypaint') libpath_compiled = join(prefix, 'lib', 'mypaint') # or lib64? sys.path.insert(0, libpath) sys.path.insert(0, libpath_compiled) sys.path.insert(0, join(prefix, 'share')) # for libmypaint localepath = join(prefix, 'share', 'locale') localepath_brushlib = localepath extradata = join(prefix, 'share') elif all(map(os.path.exists, ['brushlib', 'desktop', 'gui', 'lib'])): # Testing from within the source tree. prefix = None libpath = u'.' extradata = u'desktop' localepath = 'po' localepath_brushlib = 'brushlib/po' elif sys.platform == 'win32': prefix = None # this is py2exe point of view, all executables in root of installdir # FIXME: not all win32 launches are py2exe; need a better test libpath = os.path.realpath(scriptdir) sys.path.insert(0, libpath) sys.path.insert(0, join(prefix, 'share')) # for libmypaint localepath = join(libpath, 'share', 'locale') localepath_brushlib = localepath extradata = join(libpath, 'share') else: raise RuntimeError("Unknown install type; could not determine paths") assert isinstance(libpath, unicode) try: # just for a nice error message from lib import mypaintlib except ImportError: logger.critical("We are not correctly installed or compiled!") logger.critical('script: %r', sys.argv[0]) if prefix: logger.critical('deduced prefix: %r', prefix) logger.critical('lib_shared: %r', libpath) logger.critical('lib_compiled: %r', libpath_compiled) raise datapath = libpath if not os.path.isdir(join(datapath, 'brushes')): logger.critical('Default brush collection not found!') logger.critical('It should have been here: %r', datapath) sys.exit(1) # Old style config file and user data locations. # Return None if using XDG will be correct. if sys.platform == 'win32': old_confpath = None else: from lib import helpers homepath = helpers.expanduser_unicode(u'~') old_confpath = join(homepath, '.mypaint/') if old_confpath: if not os.path.isdir(old_confpath): old_confpath = None else: logger.info("There is an old-style configuration area in %r", old_confpath) logger.info("Its contents can be migrated to $XDG_CONFIG_HOME " "and $XDG_DATA_HOME if you wish.") logger.info("See the XDG Base Directory Specification for info.") assert isinstance(old_confpath, unicode) or old_confpath is None assert isinstance(datapath, unicode) assert isinstance(extradata, unicode) return datapath, extradata, old_confpath, localepath, localepath_brushlib
def get_paths(): join = os.path.join # Convert sys.argv to a list of unicode objects # (actually converting sys.argv confuses gtk, thus we add a new variable) if sys.platform == "win32": sys.argv_unicode = win32_unicode_argv() else: sys.argv_unicode = [s.decode(sys.getfilesystemencoding()) for s in sys.argv] # Script and its location, in canonical absolute form scriptfile = os.path.abspath(os.path.normpath(sys.argv_unicode[0])) scriptdir = os.path.dirname(scriptfile) assert isinstance(scriptfile, unicode) assert isinstance(scriptdir, unicode) # Determine $prefix dir_install = scriptdir if os.path.basename(dir_install) == "bin": # This is a normal POSIX installation. prefix = os.path.dirname(dir_install) assert isinstance(prefix, unicode) libpath = join(prefix, "share", "mypaint") libpath_compiled = join(prefix, "lib", "mypaint") # or lib64? sys.path.insert(0, libpath) sys.path.insert(0, libpath_compiled) sys.path.insert(0, join(prefix, "share")) # for libmypaint localepath = join(prefix, "share", "locale") localepath_brushlib = localepath extradata = join(prefix, "share") elif all(map(os.path.exists, ["brushlib", "desktop", "gui", "lib"])): # Testing from within the source tree. prefix = None libpath = u"." extradata = u"desktop" localepath = "po" localepath_brushlib = "brushlib/po" elif sys.platform == "win32": prefix = None # this is py2exe point of view, all executables in root of installdir # FIXME: not all win32 launches are py2exe; need a better test libpath = os.path.realpath(scriptdir) sys.path.insert(0, libpath) sys.path.insert(0, join(prefix, "share")) # for libmypaint localepath = join(libpath, "share", "locale") localepath_brushlib = localepath extradata = join(libpath, "share") else: raise RuntimeError("Unknown install type; could not determine paths") assert isinstance(libpath, unicode) try: # just for a nice error message from lib import mypaintlib except ImportError: logger.critical("We are not correctly installed or compiled!") logger.critical("script: %r", sys.argv[0]) if prefix: logger.critical("deduced prefix: %r", prefix) logger.critical("lib_shared: %r", libpath) logger.critical("lib_compiled: %r", libpath_compiled) raise datapath = libpath if not os.path.isdir(join(datapath, "brushes")): logger.critical("Default brush collection not found!") logger.critical("It should have been here: %r", datapath) sys.exit(1) # Old style config file and user data locations. # Return None if using XDG will be correct. if sys.platform == "win32": old_confpath = None else: from lib import helpers homepath = helpers.expanduser_unicode(u"~") old_confpath = join(homepath, ".mypaint/") if old_confpath: if not os.path.isdir(old_confpath): old_confpath = None else: logger.info("There is an old-style configuration area in %r", old_confpath) logger.info("Its contents can be migrated to $XDG_CONFIG_HOME " "and $XDG_DATA_HOME if you wish.") logger.info("See the XDG Base Directory Specification for info.") assert isinstance(old_confpath, unicode) or old_confpath is None assert isinstance(datapath, unicode) assert isinstance(extradata, unicode) return datapath, extradata, old_confpath, localepath, localepath_brushlib
def get_paths(): join = os.path.join # Convert sys.argv to a list of unicode objects # (actually converting sys.argv confuses gtk, thus we add a new variable) if sys.platform == 'win32': sys.argv_unicode = win32_unicode_argv() else: sys.argv_unicode = [s.decode(sys.getfilesystemencoding()) for s in sys.argv] # Script and its location, in canonical absolute form scriptfile = os.path.abspath(os.path.normpath(sys.argv_unicode[0])) scriptdir = os.path.dirname(scriptfile) assert isinstance(scriptfile, unicode) assert isinstance(scriptdir, unicode) # Determine $prefix dir_install = scriptdir if os.path.basename(dir_install) == 'bin': # This is a normal POSIX-like installation. # The Windows standalone distribution works like this too. prefix = os.path.dirname(dir_install) assert isinstance(prefix, unicode) libpath = join(prefix, 'share', 'mypaint') libpath_compiled = join(prefix, 'lib', 'mypaint') # or lib64? sys.path.insert(0, libpath) sys.path.insert(0, libpath_compiled) sys.path.insert(0, join(prefix, 'share')) # for libmypaint localepath = join(prefix, 'share', 'locale') localepath_brushlib = localepath extradata = join(prefix, 'share') elif all(map(os.path.exists, ['brushlib', 'desktop', 'gui', 'lib'])): # Testing from within the source tree. prefix = None libpath = u'.' extradata = u'desktop' localepath = 'po' localepath_brushlib = 'brushlib/po' elif sys.platform == 'win32': prefix = None # this is py2exe point of view, all executables in root of installdir # FIXME: not all win32 launches are py2exe; need a better test libpath = os.path.realpath(scriptdir) sys.path.insert(0, libpath) sys.path.insert(0, join(prefix, 'share')) # for libmypaint localepath = join(libpath, 'share', 'locale') localepath_brushlib = localepath extradata = join(libpath, 'share') else: raise RuntimeError("Unknown install type; could not determine paths") assert isinstance(libpath, unicode) try: # just for a nice error message from lib import mypaintlib except ImportError: logger.exception( "Failed to load MyPaint's C extension. " "This probably means that MyPaint was not correctly " "installed, or was built incorrectly." ) logger.info('script: %r', sys.argv[0]) logger.info('deduced prefix: %r', prefix) logger.info('lib_shared: %r', libpath) logger.info('lib_compiled: %r', libpath_compiled) logger.info('sys.path: %r', sys.path) sys.exit(1) datapath = libpath if not os.path.isdir(join(datapath, 'brushes')): logger.critical('Default brush collection not found!') logger.critical('It should have been here: %r', datapath) sys.exit(1) # Old style config file and user data locations. # Return None if using XDG will be correct. if sys.platform == 'win32': old_confpath = None else: from lib import helpers homepath = helpers.expanduser_unicode(u'~') old_confpath = join(homepath, '.mypaint/') if old_confpath: if not os.path.isdir(old_confpath): old_confpath = None else: logger.info("There is an old-style configuration area in %r", old_confpath) logger.info("Its contents can be migrated to $XDG_CONFIG_HOME " "and $XDG_DATA_HOME if you wish.") logger.info("See the XDG Base Directory Specification for info.") assert isinstance(old_confpath, unicode) or old_confpath is None assert isinstance(datapath, unicode) assert isinstance(extradata, unicode) return datapath, extradata, old_confpath, localepath, localepath_brushlib