Mercurial > libervia-backend
comparison sat/tools/config.py @ 3053:8b36e5c3f28f
misc: don't import memory in launch script:
launch script was importing a method from memory (fixLocalDir), but memory is importing
twisted.internet.reactor which can result to a ReactorAlreadyInstalledError.
This patch fixes it by moving fixLocalDir to tools/config.
The launch script is now using /usr/bin/env.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 08 Oct 2019 12:10:26 +0200 |
parents | 98d1f34ce5b9 |
children | 9d0df638c8b4 |
comparison
equal
deleted
inserted
replaced
3052:60a63723ecea | 3053:8b36e5c3f28f |
---|---|
68 log.warning(_("Config auto-update: {option} set to {value} in the file " | 68 log.warning(_("Config auto-update: {option} set to {value} in the file " |
69 "{config_file}.").format(option=option, value=value, | 69 "{config_file}.").format(option=option, value=value, |
70 config_file=target_file)) | 70 config_file=target_file)) |
71 | 71 |
72 | 72 |
73 # XXX: tmp update code, will be removed in the future | |
74 # When you remove this, please add the default value for | |
75 # 'local_dir' in sat.core.constants.Const.DEFAULT_CONFIG | |
76 def fixLocalDir(silent=True): | |
77 """Retro-compatibility with the previous local_dir default value. | |
78 | |
79 @param silent (boolean): toggle logging output (must be True when called from sat.sh) | |
80 """ | |
81 user_config = ConfigParser() | |
82 try: | |
83 user_config.read(C.CONFIG_FILES) | |
84 except: | |
85 pass # file is readable but its structure if wrong | |
86 try: | |
87 current_value = user_config.get("DEFAULT", "local_dir") | |
88 except (NoOptionError, NoSectionError): | |
89 current_value = "" | |
90 if current_value: | |
91 return # nothing to do | |
92 old_default = "~/.sat" | |
93 if os.path.isfile(os.path.expanduser(old_default) + "/" + C.SAVEFILE_DATABASE): | |
94 if not silent: | |
95 log.warning(_( | |
96 "A database has been found in the default local_dir for previous " | |
97 "versions (< 0.5)" | |
98 )) | |
99 fixConfigOption("", "local_dir", old_default, silent) | |
100 | |
101 | |
73 def parseMainConf(): | 102 def parseMainConf(): |
74 """look for main .ini configuration file, and parse it""" | 103 """look for main .ini configuration file, and parse it""" |
75 config = ConfigParser(defaults=C.DEFAULT_CONFIG) | 104 config = ConfigParser(defaults=C.DEFAULT_CONFIG) |
76 try: | 105 try: |
77 config.read(C.CONFIG_FILES) | 106 config.read(C.CONFIG_FILES) |