[FIX] cli: allows multiple addons path: --addons-path=path1,path2 , path3

This was only possible in the config file.

lp bug: https://launchpad.net/bugs/507973 fixed

bzr revid: jth@openerp.com-20110430152505-t57u24s2a1am3bjh
This commit is contained in:
Julien Thewys
2011-04-30 17:25:05 +02:00
parent baa9d24adf
commit 2ad296f925
+20 -18
View File
@@ -412,26 +412,28 @@ class configmanager(object):
import stat
os.chmod(filename, stat.S_IRUSR + stat.S_IWUSR)
def _is_addons_path(self, path):
for f in os.listdir(path):
modpath = os.path.join(path, f)
if os.path.isdir(modpath):
def hasfile(filename):
return os.path.isfile(os.path.join(modpath, filename))
if hasfile('__init__.py') and (hasfile('__openerp__.py') or hasfile('__terp__.py')):
return True
return False
def _check_addons_path(self, option, opt, value, parser):
res = os.path.abspath(os.path.expanduser(value))
if not os.path.exists(res):
raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, value))
ad_paths = []
for path in value.split(','):
path = path.strip()
res = os.path.abspath(os.path.expanduser(path))
if not os.path.isdir(res):
raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, path))
if not self._is_addons_path(res):
raise optparse.OptionValueError("option %s: The addons-path %r does not seem to a be a valid Addons Directory!" % (opt, path))
ad_paths.append(res)
contains_addons = False
for f in os.listdir(res):
modpath = os.path.join(res, f)
if os.path.isdir(modpath) and \
os.path.exists(os.path.join(modpath, '__init__.py')) and \
(os.path.exists(os.path.join(modpath, '__openerp__.py')) or \
os.path.exists(os.path.join(modpath, '__terp__.py'))):
contains_addons = True
break
if not contains_addons:
raise optparse.OptionValueError("option %s: The addons-path %r does not seem to a be a valid Addons Directory!" % (opt, value))
setattr(parser.values, option.dest, res)
setattr(parser.values, option.dest, ",".join(ad_paths))
def load(self):
p = ConfigParser.ConfigParser()