From c4e41d699797e7919a54a0a9aa198e415ec690f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 17:44:31 +0100 Subject: [PATCH 1/6] Make some paths available before profile init --- src/common/configpaths.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/common/configpaths.py b/src/common/configpaths.py index cf4792c24..99d23b3b2 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -97,6 +97,13 @@ class ConfigPaths: base = expand('~/.local/share') self.data_root = os.path.join(base, 'gajim') + basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir)) + self.add('DATA', None, os.path.join(basedir, windowsify('data'))) + self.add('ICONS', None, os.path.join(basedir, windowsify('icons'))) + self.add('HOME', None, fse(os.path.expanduser('~'))) + self.add('PLUGINS_BASE', None, + os.path.join(basedir, windowsify('plugins'))) + def add(self, name, type_, path): self.paths[name] = (type_, path) @@ -125,12 +132,12 @@ class ConfigPaths: self.config_root = self.cache_root = self.data_root = root self.init_profile(profile) - + if len(profile) > 0 and profile_separation: profile = u'.' + profile else: profile = '' - + d = {'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem', 'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets', 'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities', @@ -159,12 +166,6 @@ class ConfigPaths: else: self.add('MY_CONFIG', TYPE_CONFIG, '') - basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir)) - self.add('DATA', None, os.path.join(basedir, windowsify('data'))) - self.add('ICONS', None, os.path.join(basedir, windowsify('icons'))) - self.add('HOME', None, fse(os.path.expanduser('~'))) - self.add('PLUGINS_BASE', None, os.path.join(basedir, - windowsify('plugins'))) try: self.add('TMP', None, fse(tempfile.gettempdir())) except IOError as e: From 5af42e470775d8b6516fa80414fd1deedc5e5449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 17:45:12 +0100 Subject: [PATCH 2/6] Remove old svn code --- src/common/configpaths.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 99d23b3b2..6a998b979 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -173,12 +173,6 @@ class ConfigPaths: os.path.expanduser('~')), file=sys.stderr) self.add('TMP', None, fse(os.path.expanduser('~'))) - try: - import svn_config - svn_config.configure(self) - except (ImportError, AttributeError): - pass - def init_profile(self, profile): conffile = windowsify('config') secretsfile = windowsify('secrets') From 52657e7f1895a777c589bad49c0961a4468a3e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 18:08:52 +0100 Subject: [PATCH 3/6] Remove unicode conversion method for paths its not needed in python3 - tempfile.gettempdir() returns always unicode - os.environ.get() returns always unicode we get what we put into: - os.path.expanduser() --- src/common/check_paths.py | 7 ++----- src/common/configpaths.py | 16 ++++++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/common/check_paths.py b/src/common/check_paths.py index 5e92c324a..71dcf2f4d 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -130,9 +130,7 @@ def split_db(): print('spliting database') if os.name == 'nt': try: - import configpaths - OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse( - os.environ['appdata']), 'Gajim') + OLD_LOG_DB_FOLDER = os.path.join(os.environ['appdata'], 'Gajim') except KeyError: OLD_LOG_DB_FOLDER = '.' else: @@ -187,8 +185,7 @@ def check_and_possibly_move_config(): if os.name == 'nt': try: - OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse( - os.environ['appdata']), 'Gajim') + OLD_LOG_DB_FOLDER = os.path.join(os.environ['appdata'], 'Gajim') except KeyError: OLD_LOG_DB_FOLDER = '.' else: diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 6a998b979..29f1b0fa5 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -52,17 +52,13 @@ TYPE_DATA # just leave it as is. Since these paths are meant to be internal to Gajim and # not displayed to the user, Unicode is not really necessary here. -def fse(s): - """ - Convert from filesystem encoding if not already Unicode - """ - return s def windowsify(s): if os.name == 'nt': return s.capitalize() return s + class ConfigPaths: def __init__(self): # {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA @@ -77,7 +73,7 @@ class ConfigPaths: # variable 'appdata' is in? Assuming it to be in filesystem # encoding. self.config_root = self.cache_root = self.data_root = \ - os.path.join(fse(os.environ['appdata']), 'Gajim') + os.path.join(os.environ['appdata'], 'Gajim') except KeyError: # win9x, in cwd self.config_root = self.cache_root = self.data_root = '.' @@ -97,10 +93,10 @@ class ConfigPaths: base = expand('~/.local/share') self.data_root = os.path.join(base, 'gajim') - basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir)) + basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir) self.add('DATA', None, os.path.join(basedir, windowsify('data'))) self.add('ICONS', None, os.path.join(basedir, windowsify('icons'))) - self.add('HOME', None, fse(os.path.expanduser('~'))) + self.add('HOME', None, os.path.expanduser('~')) self.add('PLUGINS_BASE', None, os.path.join(basedir, windowsify('plugins'))) @@ -167,11 +163,11 @@ class ConfigPaths: self.add('MY_CONFIG', TYPE_CONFIG, '') try: - self.add('TMP', None, fse(tempfile.gettempdir())) + self.add('TMP', None, tempfile.gettempdir()) except IOError as e: print('Error opening tmp folder: %s\nUsing %s' % (str(e), os.path.expanduser('~')), file=sys.stderr) - self.add('TMP', None, fse(os.path.expanduser('~'))) + self.add('TMP', None, os.path.expanduser('~')) def init_profile(self, profile): conffile = windowsify('config') From 8079930de08e07a56b0e918b39b81c00b024d6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 19:38:51 +0100 Subject: [PATCH 4/6] Add get() function to configpaths --- src/common/configpaths.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 29f1b0fa5..aa58659a4 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -59,6 +59,10 @@ def windowsify(s): return s +def get(key): + return gajimpaths[key] + + class ConfigPaths: def __init__(self): # {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA From 6d26553b6501a109458ce12e7363c11c2e2af1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 19:49:16 +0100 Subject: [PATCH 5/6] Dont windowsify non-config directorys --- src/common/configpaths.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/configpaths.py b/src/common/configpaths.py index aa58659a4..fbc5e2690 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -98,11 +98,10 @@ class ConfigPaths: self.data_root = os.path.join(base, 'gajim') basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir) - self.add('DATA', None, os.path.join(basedir, windowsify('data'))) - self.add('ICONS', None, os.path.join(basedir, windowsify('icons'))) + self.add('DATA', None, os.path.join(basedir, 'data')) + self.add('ICONS', None, os.path.join(basedir, 'icons')) self.add('HOME', None, os.path.expanduser('~')) - self.add('PLUGINS_BASE', None, - os.path.join(basedir, windowsify('plugins'))) + self.add('PLUGINS_BASE', None, os.path.join(basedir, 'plugins')) def add(self, name, type_, path): self.paths[name] = (type_, path) From 8c01d4d49fe9e9bbb9c9db1d47d193300d281481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 6 Jan 2017 19:52:50 +0100 Subject: [PATCH 6/6] Add GUI folder to configpaths --- src/common/configpaths.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/configpaths.py b/src/common/configpaths.py index fbc5e2690..717541700 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -99,6 +99,7 @@ class ConfigPaths: basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir) self.add('DATA', None, os.path.join(basedir, 'data')) + self.add('GUI', None, os.path.join(basedir, 'data', 'gui')) self.add('ICONS', None, os.path.join(basedir, 'icons')) self.add('HOME', None, os.path.expanduser('~')) self.add('PLUGINS_BASE', None, os.path.join(basedir, 'plugins'))