[ADD]:suppot for __openerp__.py or __terp__.py

bzr revid: rvo@tinyerp.co.in-20100311084941-1l92enpyz1a98hrr
This commit is contained in:
Rvo (Open ERP) 2010-03-11 14:19:41 +05:30
parent 0dfa91ac8a
commit 587828161d
6 changed files with 54 additions and 30 deletions

View File

@ -221,7 +221,7 @@ def get_module_as_zip_from_module_directory(module_directory, b64enc=True, src=T
base = os.path.basename(path)
for f in tools.osutil.listdir(path, True):
bf = os.path.basename(f)
if not RE_exclude.search(bf) and (src or bf == '__terp__.py' or not bf.endswith('.py')):
if not RE_exclude.search(bf) and (src or bf == '__openerp__.py' or bf == '__terp__.py' or not bf.endswith('.py')):
archive.write(os.path.join(path, f), os.path.join(base, f))
archname = StringIO()
@ -298,8 +298,10 @@ def get_modules_with_version():
modules = get_modules()
res = {}
for module in modules:
terp = get_module_resource(module, '__terp__.py')
try:
terp = get_module_resource(module, '__openerp__.py')
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'])
except Exception, e:
@ -318,13 +320,17 @@ def upgrade_graph(graph, cr, module_list, force=None):
len_graph = len(graph)
for module in module_list:
mod_path = get_module_path(module)
terp_file = get_module_resource(module, '__openerp__.py')
if not os.path.isfile(terp_file):
terp_file = get_module_resource(module, '__terp__.py')
if not mod_path or not terp_file:
global not_loaded
not_loaded.append(module)
logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: not installable' % (module))
raise osv.osv.except_osv('Error!',"Module '%s' was not found" % (module,))
if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'):
try:
info = eval(tools.file_open(terp_file).read())
@ -716,7 +722,6 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
# NOTE: Try to also load the modules that have been marked as uninstallable previously...
STATES_TO_LOAD = ['installed', 'to upgrade', 'uninstallable']
graph = create_graph(cr, ['base'], force)
has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
global not_loaded
@ -761,6 +766,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
if new_modules_in_graph == 0:
# nothing to load
break
logger.notifyChannel('init', netsvc.LOG_DEBUG, 'Updating graph with %d more modules' % (len(module_list)))
r = load_module_graph(cr, graph, status, report=report)
has_updates = has_updates or r

View File

@ -65,7 +65,10 @@ class module(osv.osv):
def get_module_info(self, name):
try:
f = tools.file_open(os.path.join(name, '__terp__.py'))
terp_file = addons.get_module_resource(name, '__openerp__.py')
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:

View File

@ -32,7 +32,8 @@ if len(sys.argv) == 2 and (sys.argv[1] in ['-h', '--help']):
modules = sys.argv[1:]
if not len(modules):
modules = map(os.path.dirname, glob.glob(os.path.join('*', '__terp__.py')))
modules = map(os.path.dirname, glob.glob(os.path.join('*', '__openerp__.py')))
modules += map(os.path.dirname, glob.glob(os.path.join('*', '__terp__.py')))
done = []
@ -40,7 +41,11 @@ print 'digraph G {'
while len(modules):
f = modules.pop(0)
done.append(f)
if os.path.isfile(os.path.join(f,"__terp__.py")):
terp_file = os.path.join(f,"__openerp__.py")
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):
for name in info['depends']:

View File

@ -356,7 +356,7 @@ class configmanager(object):
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, '__terp__.py')):
('|', os.path.exists(os.path.join(modpath, '__openerp__.py')), os.path.exists(os.path.join(modpath, '__terp__.py'))):
contains_addons = True
break

View File

@ -50,13 +50,19 @@ def init_db(cr):
cr.commit()
for i in addons.get_modules():
terp_file = addons.get_module_resource(i, '__terp__.py')
terp_file = addons.get_module_resource(i, '__openerp__.py')
mod_path = addons.get_module_path(i)
if not mod_path:
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 = eval(file_open(terp_file).read())
if info:
categs = info.get('category', 'Uncategorized').split('/')
p_id = None

View File

@ -77,7 +77,7 @@ def check_modules():
def find_addons():
for root, _, names in os.walk(join('bin', 'addons')):
if '__terp__.py' in names:
if '__openerp__.py' or '__terp__.py' in names:
yield basename(root), root
#look for extra modules
try:
@ -86,7 +86,11 @@ def find_addons():
mname = mname.strip()
if not mname:
continue
if os.path.exists(join(empath, mname, '__terp__.py')):
terp = join(empath, mname, '__openerp__.py')
if not os.path.exists(terp):
terp = join(empath, mname, '__terp__.py')
if os.path.exists(terp):
yield mname, join(empath, mname)
else:
print "Module %s specified, but no valid path." % mname