Read config file path from TRYTOND_CONFIG env variable if no config file is specified.

issue3323
review1004002
This commit is contained in:
Vincent van der Leun
2013-08-30 15:26:17 +02:00
parent ff16377e0a
commit 90e019e01b
2 changed files with 14 additions and 10 deletions
+3 -1
View File
@@ -43,7 +43,9 @@ def parse_commandline():
parser.epilog = 'The first time a database is initialized with "-i" admin'\
' password is read from file defined by TRYTONPASSFILE '\
'environment variable or interactively ask user'
'environment variable or interactively ask user. '\
'The config file can be specified in the TRYTOND_CONFIG '\
'environment variable.'
(opt, _) = parser.parse_args()
+11 -9
View File
@@ -108,15 +108,17 @@ class ConfigManager(object):
def update_etc(self, configfile=None):
if configfile is None:
prefixdir = os.path.abspath(os.path.normpath(os.path.join(
os.path.dirname(sys.prefix), '..')))
configfile = os.path.join(prefixdir, 'etc', 'trytond.conf')
if not os.path.isfile(configfile):
configdir = os.path.abspath(os.path.normpath(os.path.join(
os.path.dirname(__file__), '..')))
configfile = os.path.join(configdir, 'etc', 'trytond.conf')
if not os.path.isfile(configfile):
configfile = None
configfile = os.environ.get('TRYTOND_CONFIG')
if not configfile:
prefixdir = os.path.abspath(os.path.normpath(os.path.join(
os.path.dirname(sys.prefix), '..')))
configfile = os.path.join(prefixdir, 'etc', 'trytond.conf')
if not os.path.isfile(configfile):
configdir = os.path.abspath(os.path.normpath(os.path.join(
os.path.dirname(__file__), '..')))
configfile = os.path.join(configdir, 'etc', 'trytond.conf')
if not os.path.isfile(configfile):
configfile = None
self.configfile = configfile
if not self.configfile: