for k, v in additional_data[package.name].items():
setattr(package, k, v)
- def add_module(self, cr, module, force=None):
- self.add_modules(cr, [module], force)
+ def add_module(self, cr, module, force_demo=False):
+ self.add_modules(cr, [module], force_demo)
- def add_modules(self, cr, module_list, force=None):
- if force is None:
- force = []
+ def add_modules(self, cr, module_list, force_demo=False):
packages = []
len_graph = len(self)
for module in module_list:
+ if force_demo:
+ cr.execute("""
+ UPDATE ir_module_module
+ SET demo='t'
+ WHERE name = %s""",
+ (module,))
# This will raise an exception if no/unreadable descriptor file.
# NOTE The call to load_information_from_description_file is already
# done by db.initialize, so it is possible to not do it again here.
current.remove(package)
node = self.add_node(package, info)
node.data = info
- for kind in ('init', 'demo', 'update'):
- if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force:
- setattr(node, kind, True)
else:
later.add(package)
packages.append((package, info))
level = 0
done = set(self.keys())
while done:
- level_modules = [(name, module) for name, module in self.items() if module.depth==level]
+ level_modules = sorted((name, module) for name, module in self.items() if module.depth==level)
for name, module in level_modules:
done.remove(name)
yield module
node.depth = self.depth + 1
if node not in self.children:
self.children.append(node)
- for attr in ('init', 'update', 'demo'):
- if hasattr(self, attr):
- setattr(node, attr, True)
self.children.sort(lambda x, y: cmp(x.name, y.name))
return node
def __setattr__(self, name, value):
super(Singleton, self).__setattr__(name, value)
- if name in ('init', 'update', 'demo'):
- tools.config[name][self.name] = 1
- for child in self.children:
- setattr(child, name, value)
if name == 'depth':
for child in self.children:
setattr(child, name, value + 1)
import os
import re
import sys
+ import threading
import zipfile
import zipimport
cr.commit()
if not tools.config.options['test_disable']:
try:
+ threading.currentThread().testing = True
_load_data(cr, module_name, idref, mode, 'test')
except Exception, e:
logging.getLogger('init.test').exception(
'Tests failed to execute in module %s', module_name)
finally:
+ threading.currentThread().testing = False
if tools.config.options['test_commit']:
cr.commit()
else:
register_module_classes(package.name)
models = pool.load(cr, package)
loaded_modules.append(package.name)
- if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
+ if package.state in ('to install', 'to upgrade'):
init_module_models(cr, package.name, models)
status['progress'] = float(index) / len(graph)
idref = {}
- mode = 'update'
- if hasattr(package, 'init') or package.state == 'to install':
+ if package.state == 'to install':
mode = 'init'
+ else:
+ mode = 'update'
- if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
+ if package.state in ('to install', 'to upgrade'):
if package.state=='to upgrade':
# upgrading the module information
modobj.write(cr, 1, [module_id], modobj.get_values_from_terp(package.data))
load_init_xml(module_name, idref, mode)
load_update_xml(module_name, idref, mode)
load_data(module_name, idref, mode)
- if hasattr(package, 'demo') or (package.dbdemo and package.state != 'installed'):
+ if package.dbdemo and package.state != 'installed':
status['progress'] = (index + 0.75) / len(graph)
load_demo_xml(module_name, idref, mode)
load_demo(module_name, idref, mode)
modobj.update_translations(cr, 1, [module_id], None)
package.state = 'installed'
- for kind in ('init', 'demo', 'update'):
- if hasattr(package, kind):
- delattr(package, kind)
cr.commit()
if not openerp.modules.db.is_initialized(cr):
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
openerp.modules.db.initialize(cr)
- tools.config["init"]["all"] = 1
- tools.config['update']['all'] = 1
- if not tools.config['without_demo']:
- tools.config["demo"]['all'] = 1
+ update_module = True
# This is a brand new pool, just created in pooler.get_db_and_pool()
pool = pooler.get_pool(cr.dbname)
# STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps)
graph = openerp.modules.graph.Graph()
- graph.add_module(cr, 'base', force)
+ graph.add_module(cr, 'base', force_demo)
if not graph:
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)')
raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)'))
# processed_modules: for cleanup step after install
# loaded_modules: to avoid double loading
- loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
+ # After load_module_graph(), 'base' has been installed or updated and its state is 'installed'.
+ loaded_modules, processed_modules = load_module_graph(cr, graph, status, report=report)
if tools.config['load_language']:
for lang in tools.config['load_language'].split(','):
tools.load_language(cr, lang)
# STEP 2: Mark other modules to be loaded/updated
+ # This is a one-shot use of tools.config[init|update] from the command line
+ # arguments. It is directly cleared to not interfer with later create/update
+ # issued via RPC.
if update_module:
modobj = pool.get('ir.module.module')
- if ('base' in tools.config['init']) or ('base' in tools.config['update']):
+ if ('base' in tools.config['init']) or ('base' in tools.config['update']) \
+ or ('all' in tools.config['init']) or ('all' in tools.config['update']):
logger.notifyChannel('init', netsvc.LOG_INFO, 'updating modules list')
modobj.update_list(cr, 1)
- _check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys()))
+ if 'all' in tools.config['init']:
+ ids = modobj.search(cr, 1, [])
+ tools.config['init'] = dict.fromkeys([m['name'] for m in modobj.read(cr, 1, ids, ['name'])], 1)
- mods = [k for k in tools.config['init'] if tools.config['init'][k]]
- if mods:
- ids = modobj.search(cr, 1, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)])
- if ids:
- modobj.button_install(cr, 1, ids)
+ _check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys()))
- mods = [k for k in tools.config['update'] if tools.config['update'][k]]
- if mods:
- ids = modobj.search(cr, 1, ['&', ('state', '=', 'installed'), ('name', 'in', mods)])
- if ids:
- modobj.button_upgrade(cr, 1, ids)
+ mods = [k for k in tools.config['init'] if tools.config['init'][k] and k not in ('base', 'all')]
+ ids = modobj.search(cr, 1, ['&', ('state', '=', 'uninstalled'), ('name', 'in', mods)])
+ if ids:
+ modobj.button_install(cr, 1, ids) # goes from 'uninstalled' to 'to install'
- cr.execute("update ir_module_module set state=%s where name=%s", ('installed', 'base'))
+ mods = [k for k in tools.config['update'] if tools.config['update'][k] and k not in ('base', 'all')]
+ ids = modobj.search(cr, 1, ['&', ('state', '=', 'installed'), ('name', 'in', mods)])
+ if ids:
+ modobj.button_upgrade(cr, 1, ids) # goes from 'installed' to 'to upgrade'
+ for kind in ('init', 'demo', 'update'):
+ tools.config[kind] = {}
# STEP 3: Load marked modules (skipping base which was done in STEP 1)
# IMPORTANT: this is done in two parts, first loading all installed or
if report.get_report():
logger.notifyChannel('init', netsvc.LOG_INFO, report)
- for kind in ('init', 'demo', 'update'):
- tools.config[kind] = {}
-
cr.commit()
if update_module:
# Remove records referenced from ir_model_data for modules to be
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
-import os
-import re
-import sys
-from setuptools import setup, find_packages
+import glob, os, re, setuptools, sys
+from os.path import join, isfile
-execfile('addons/web/common/release.py')
+# List all data files
+def data():
+ files = []
+ for root, dirnames, filenames in os.walk('openerp'):
+ for filename in filenames:
+ if not re.match(r'.*(\.pyc|\.pyo|\~)$',filename):
+ files.append(os.path.join(root, filename))
+ d = {}
+ for v in files:
+ k=os.path.dirname(v)
+ if k in d:
+ d[k].append(v)
+ else:
+ d[k]=[v]
+ r = d.items()
++ if os.name == 'nt':
++ r.append(("Microsoft.VC90.CRT", glob.glob('C:\Microsoft.VC90.CRT\*.*')))
+ return r
-version_dash_incompatible = False
-if 'bdist_rpm' in sys.argv:
- version_dash_incompatible = True
-try:
- import py2exe
- from py2exe_utils import opts
- version_dash_incompatible = True
-except ImportError:
- opts = {}
-if version_dash_incompatible:
- version = version.split('-')[0]
+def gen_manifest():
+ file_list="\n".join(data())
+ open('MANIFEST','w').write(file_list)
-FILE_PATTERNS = \
- r'.+\.(py|cfg|po|pot|mo|txt|rst|gif|png|jpg|ico|mako|html|js|css|htc|swf)$'
-def find_data_files(source, patterns=FILE_PATTERNS):
- file_matcher = re.compile(patterns, re.I)
- out = []
- for base, _, files in os.walk(source):
- cur_files = []
- for f in files:
- if file_matcher.match(f):
- cur_files.append(os.path.join(base, f))
- if cur_files:
- out.append(
- (base, cur_files))
++if os.name == 'nt':
++ sys.path.append("C:\Microsoft.VC90.CRT")
+
- return out
+def py2exe_options():
+ if os.name == 'nt':
+ import py2exe
+ return {
- "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("pixmaps","openerp-icon.ico"))], }],
++ "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], }],
+ 'options' : {
+ "py2exe": {
+ "skip_archive": 1,
+ "optimize": 2,
+ "dist_dir": 'dist',
- "packages": [ "DAV", "HTMLParser", "PIL", "asynchat", "asyncore", "commands", "dateutil", "decimal", "email", "encodings", "imaplib", "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify", "mako", "openerp", "poplib", "pychart", "pydot", "pyparsing", "reportlab", "select", "simplejson", "smtplib", "uuid", "vatnumber" "vobject", "xml", "xml", "xml.dom", "xml.xpath", "yaml", ],
++ "packages": [ "DAV", "HTMLParser", "PIL", "asynchat", "asyncore", "commands", "dateutil", "decimal", "email", "encodings", "imaplib", "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify", "mako", "openerp", "poplib", "pychart", "pydot", "pyparsing", "reportlab", "select", "simplejson", "smtplib", "uuid", "vatnumber", "vobject", "xml", "xml.dom", "yaml", ],
+ "excludes" : ["Tkconstants","Tkinter","tcl"],
+ }
+ }
+ }
+ else:
+ return {}
-setup(
- name=name,
- version=version,
- description=description,
- long_description=long_description,
- author=author,
- author_email=author_email,
- url=url,
- download_url=download_url,
- license=license,
- install_requires=[
- "Babel >= 0.9.6",
- "simplejson >= 2.0.9",
- "python-dateutil >= 1.4.1, < 2",
- "pytz",
- "werkzeug == 0.7",
- ],
- tests_require=[
- 'unittest2',
- 'mock',
- ],
- test_suite = 'unittest2.collector',
- zip_safe=False,
- packages=find_packages(),
- classifiers=[
- 'Development Status :: 6 - Production/Stable',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python',
- 'Environment :: Web Environment',
- 'Topic :: Office/Business :: Financial',
- ],
- scripts=['openerp-web'],
- data_files=(find_data_files('addons')
- + opts.pop('data_files', [])
- ),
- **opts
+execfile(join(os.path.dirname(__file__), 'openerp', 'release.py'))
+
+setuptools.setup(
+ name = 'openerp',
+ version = version,
+ description = description,
+ long_description = long_desc,
+ url = url,
+ author = author,
+ author_email = author_email,
+ classifiers = filter(None, classifiers.split("\n")),
+ license = license,
+ scripts = ['openerp-server'],
+ data_files = data(),
+ packages = setuptools.find_packages(),
+ #include_package_data = True,
+ install_requires = [
+ # TODO the pychart package we include in openerp corresponds to PyChart 1.37.
+ # It seems there is a single difference, which is a spurious print in generate_docs.py.
+ # It is probably safe to move to PyChart 1.39 (the latest one).
+ # (Let setup.py choose the latest one, and we should check we can remove pychart from
+ # our tree.) http://download.gna.org/pychart/
+ # TODO 'pychart',
+ 'babel',
+ 'feedparser',
+ 'gdata',
+ 'lxml',
+ 'mako',
+ 'psycopg2',
+ 'pydot',
- 'python-dateutil',
++ 'python-dateutil < 2',
+ 'python-ldap',
+ 'python-openid',
+ 'pytz',
+ 'pywebdav',
+ 'pyyaml',
+ 'reportlab',
+ 'simplejson',
+ 'vatnumber',
+ 'vobject',
+ 'werkzeug',
+ 'zsi',
+ ],
+ extras_require = {
+ 'SSL' : ['pyopenssl'],
+ },
+ **py2exe_options()
)
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: