Code improvement by stephane
bzr revid: hda@tinyerp.com-20100312061500-540cpy0cbcwxmfbq
This commit is contained in:
parent
587828161d
commit
23586fb331
|
@ -221,7 +221,7 @@ def get_module_as_zip_from_module_directory(module_directory, b64enc=True, src=T
|
||||||
base = os.path.basename(path)
|
base = os.path.basename(path)
|
||||||
for f in tools.osutil.listdir(path, True):
|
for f in tools.osutil.listdir(path, True):
|
||||||
bf = os.path.basename(f)
|
bf = os.path.basename(f)
|
||||||
if not RE_exclude.search(bf) and (src or bf == '__openerp__.py' or bf == '__terp__.py' or not bf.endswith('.py')):
|
if not RE_exclude.search(bf) and (src or bf in ('__openerp__.py', '__terp__.py') or not bf.endswith('.py')):
|
||||||
archive.write(os.path.join(path, f), os.path.join(base, f))
|
archive.write(os.path.join(path, f), os.path.join(base, f))
|
||||||
|
|
||||||
archname = StringIO()
|
archname = StringIO()
|
||||||
|
@ -294,15 +294,23 @@ def get_modules():
|
||||||
plist.extend(listdir(ad))
|
plist.extend(listdir(ad))
|
||||||
return list(set(plist))
|
return list(set(plist))
|
||||||
|
|
||||||
|
def load_information_from_description_file(module):
|
||||||
|
"""
|
||||||
|
:param module: The name of the module (sale, purchase, ...)
|
||||||
|
"""
|
||||||
|
for filename in ['__openerp__.py', '__terp__.py']:
|
||||||
|
description_file = addons.get_module_resource(module, filename)
|
||||||
|
if os.path.isfile(description_file):
|
||||||
|
return eval(tools.file_open(description_file).read())
|
||||||
|
|
||||||
|
raise Exception('The module %s does not contain a description file: __openerp__.py or __terp__.py (deprecated)')
|
||||||
|
|
||||||
def get_modules_with_version():
|
def get_modules_with_version():
|
||||||
modules = get_modules()
|
modules = get_modules()
|
||||||
res = {}
|
res = {}
|
||||||
for module in modules:
|
for module in modules:
|
||||||
try:
|
try:
|
||||||
terp = get_module_resource(module, '__openerp__.py')
|
info = load_information_from_description_file(module)
|
||||||
if not os.path.isfile(terp):
|
|
||||||
terp = addons.get_module_resource(module, '__terp__.py')
|
|
||||||
info = eval(tools.file_open(terp).read())
|
|
||||||
res[module] = "%s.%s" % (release.major_version, info['version'])
|
res[module] = "%s.%s" % (release.major_version, info['version'])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
continue
|
continue
|
||||||
|
@ -707,8 +715,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
if len(cr.fetchall())==0:
|
if len(cr.fetchall())==0:
|
||||||
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
|
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
|
||||||
tools.init_db(cr)
|
tools.init_db(cr)
|
||||||
# cr.execute("update res_users set password=%s where id=%s",('admin',1))
|
|
||||||
# in that case, force --init=all
|
|
||||||
tools.config["init"]["all"] = 1
|
tools.config["init"]["all"] = 1
|
||||||
tools.config['update']['all'] = 1
|
tools.config['update']['all'] = 1
|
||||||
if not tools.config['without_demo']:
|
if not tools.config['without_demo']:
|
||||||
|
|
|
@ -64,18 +64,13 @@ class module(osv.osv):
|
||||||
_description = "Module"
|
_description = "Module"
|
||||||
|
|
||||||
def get_module_info(self, name):
|
def get_module_info(self, name):
|
||||||
|
info = {}
|
||||||
try:
|
try:
|
||||||
terp_file = addons.get_module_resource(name, '__openerp__.py')
|
info = addons.load_information_from_description_file(name)
|
||||||
if not os.path.isfile(terp_file):
|
|
||||||
terp_file = addons.get_module_resource(name, '__terp__.py')
|
|
||||||
f = tools.file_open(terp_file)
|
|
||||||
data = f.read()
|
|
||||||
info = eval(data)
|
|
||||||
if 'version' in info:
|
if 'version' in info:
|
||||||
info['version'] = release.major_version + '.' + info['version']
|
info['version'] = release.major_version + '.' + info['version']
|
||||||
f.close()
|
|
||||||
except:
|
except:
|
||||||
return {}
|
pass
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||||
|
|
|
@ -41,12 +41,7 @@ print 'digraph G {'
|
||||||
while len(modules):
|
while len(modules):
|
||||||
f = modules.pop(0)
|
f = modules.pop(0)
|
||||||
done.append(f)
|
done.append(f)
|
||||||
terp_file = os.path.join(f,"__openerp__.py")
|
info = addons.load_information_from_description_file(f)
|
||||||
if not os.path.isfile(terp_file):
|
|
||||||
terp_file = os.path.join(f,"__terp__.py")
|
|
||||||
|
|
||||||
if os.path.isfile(terp_file):
|
|
||||||
info=eval(file(os.path.join(f,"__terp__.py")).read())
|
|
||||||
if info.get('installable', True):
|
if info.get('installable', True):
|
||||||
for name in info['depends']:
|
for name in info['depends']:
|
||||||
if name not in done+modules:
|
if name not in done+modules:
|
||||||
|
|
|
@ -352,11 +352,15 @@ class configmanager(object):
|
||||||
res = os.path.abspath(os.path.expanduser(value))
|
res = os.path.abspath(os.path.expanduser(value))
|
||||||
if not os.path.exists(res):
|
if not os.path.exists(res):
|
||||||
raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, value))
|
raise optparse.OptionValueError("option %s: no such directory: %r" % (opt, value))
|
||||||
|
|
||||||
contains_addons = False
|
contains_addons = False
|
||||||
for f in os.listdir(res):
|
for f in os.listdir(res):
|
||||||
modpath = os.path.join(res, f)
|
modpath = os.path.join(res, f)
|
||||||
if os.path.isdir(modpath) and os.path.exists(os.path.join(modpath, '__init__.py')) and \
|
if os.path.isdir(modpath) and \
|
||||||
('|', os.path.exists(os.path.join(modpath, '__openerp__.py')), os.path.exists(os.path.join(modpath, '__terp__.py'))):
|
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
|
contains_addons = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -50,20 +50,14 @@ def init_db(cr):
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
for i in addons.get_modules():
|
for i in addons.get_modules():
|
||||||
terp_file = addons.get_module_resource(i, '__openerp__.py')
|
|
||||||
mod_path = addons.get_module_path(i)
|
mod_path = addons.get_module_path(i)
|
||||||
if not mod_path:
|
if not mod_path:
|
||||||
continue
|
continue
|
||||||
info = False
|
|
||||||
# if os.path.isfile(terp_file) or os.path.isfile(mod_path+'.zip'):
|
|
||||||
# info = eval(file_open(terp_file).read())
|
|
||||||
if not os.path.isfile(terp_file):
|
|
||||||
terp_file = addons.get_module_resource(i, '__terp__.py')
|
|
||||||
|
|
||||||
if os.path.isfile(terp_file) or os.path.isfile(mod_path+'.zip'):
|
info = addons.load_information_from_description_file(i)
|
||||||
info = eval(file_open(terp_file).read())
|
|
||||||
|
|
||||||
if info:
|
if not info:
|
||||||
|
continue
|
||||||
categs = info.get('category', 'Uncategorized').split('/')
|
categs = info.get('category', 'Uncategorized').split('/')
|
||||||
p_id = None
|
p_id = None
|
||||||
while categs:
|
while categs:
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -77,7 +77,7 @@ def check_modules():
|
||||||
|
|
||||||
def find_addons():
|
def find_addons():
|
||||||
for root, _, names in os.walk(join('bin', 'addons')):
|
for root, _, names in os.walk(join('bin', 'addons')):
|
||||||
if '__openerp__.py' or '__terp__.py' in names:
|
if '__openerp__.py' in names or '__terp__.py' in names:
|
||||||
yield basename(root), root
|
yield basename(root), root
|
||||||
#look for extra modules
|
#look for extra modules
|
||||||
try:
|
try:
|
||||||
|
@ -86,6 +86,7 @@ def find_addons():
|
||||||
mname = mname.strip()
|
mname = mname.strip()
|
||||||
if not mname:
|
if not mname:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
terp = join(empath, mname, '__openerp__.py')
|
terp = join(empath, mname, '__openerp__.py')
|
||||||
if not os.path.exists(terp):
|
if not os.path.exists(terp):
|
||||||
terp = join(empath, mname, '__terp__.py')
|
terp = join(empath, mname, '__terp__.py')
|
||||||
|
|
Loading…
Reference in New Issue