Example #1
0
    def __init__(self, conffile, buildout_dir, parse_config=True):
        self.buildout_dir = buildout_dir
        self.openerp_config_file = conffile

        self._registry = self.cr = None
        if parse_config:
            config.parse_config(['-c', conffile])
def main(starter, conf, version=None, just_test=False,
         server_wide_modules=None,
         gevent_script_path=None):
    """Call the `starter` script, dispatching configuration.

    All arguments are set in the standalone script produced by buildout through
    entry point options.

    :param starter: path to the main script source file (currently
      ``openerp-server``)
    :param conf: path to the Odoo configuration file (managed by the recipe)
    :param version: Odoo major version
    :param server_wide_modules: additional server wide modules, to pass with
       the ``--load`` command-line option (ignored if the option is actually
       there on the command line)
    :type version: tuple of integers
    :param just_test: if True, only run unit tests
    """
    arguments = ['-c', conf]

    if just_test:
        arguments.extend(('--log-level',
                          'test' if version >= (6, 0) else 'info',
                          '--stop-after-init'))

        if version >= (7, 0):
            arguments.append('--test-enable')

    if server_wide_modules:
        for opt in sys.argv[1:]:
            if opt.startswith('--load'):
                break
        else:
            arguments.append('--load=' + ','.join(server_wide_modules))

    if '--install-all' in sys.argv:
        sys.argv.remove('--install-all')
        from openerp.tools import config
        # Maybe we should preparse config in all cases and therefore avoid
        # adding the '-c' on the fly ?
        # Still, cautious about pre-6.1 versions
        config.parse_config(['-c', conf])
        from openerp.modules import get_modules
        arguments.extend(('-i', ','.join(get_modules())))

    insert_args(arguments)

    if version >= (8, 0):  # always true in a.r.odoo, but keeping for now
        assert gevent_script_path is not None
        patch_odoo.do_patch(gevent_script_path)

    os.chdir(os.path.split(starter)[0])
    glob = globals()
    glob['__name__'] = '__main__'
    glob['__file__'] = starter
    sys.argv[0] = starter
    try:
        execfile(starter, globals())
    except SystemExit as exc:
        return exc.code
Example #3
0
    def __init__(self, conffile, buildout_dir, parse_config=True):
        self.buildout_dir = buildout_dir
        self.openerp_config_file = conffile

        self._registry = self.cr = None
        if parse_config:
            config.parse_config(['-c', conffile])
Example #4
0
def main(ctx, database_url, database_maxconn, redis_url, aws_access_key_id,
         aws_secret_access_key, s3_bucket, s3_dev_url, addons, demo_data,
         debug, dev, statsd_host):

    import odooku.logger
    odooku.logger.setup(debug=debug, statsd_host=statsd_host)

    # Setup S3
    import odooku.s3
    odooku.s3.configure(bucket=s3_bucket,
                        aws_access_key_id=aws_access_key_id,
                        aws_secret_access_key=aws_secret_access_key,
                        dev_url=s3_dev_url)

    # Setup Redis
    import odooku.redis
    redis_url = urlparse.urlparse(redis_url) if redis_url else None
    odooku.redis.configure(
        host=redis_url.hostname if redis_url else None,
        port=redis_url.port if redis_url else None,
        password=redis_url.password if redis_url else None,
        db_number=redis_url.path[1:] if redis_url and redis_url.path else None)

    import openerp
    # Even if 1 worker is running, we can still be running multiple
    # heroku instances.
    openerp.multi_process = True

    # Patch odoo config
    from openerp.tools import config
    database_url = urlparse.urlparse(database_url)
    config.parse_config()
    config['addons_path'] = addons
    config['db_name'] = database_url.path[1:] if database_url.path else None
    config['db_user'] = database_url.username
    config['db_password'] = database_url.password
    config['db_host'] = database_url.hostname
    config['db_port'] = database_url.port
    config['db_maxconn'] = database_maxconn

    config['demo'] = {}
    config['without_demo'] = 'all' if not demo_data else ''
    config['debug'] = debug
    config['dev_mode'] = dev
    config['list_db'] = False

    ctx.obj.update({'debug': debug, 'dev': dev, 'config': config})

    import logging
    _logger = logging.getLogger(__name__)
    _logger.info("Odoo modules at:\n%s" %
                 "\n".join(openerp.modules.module.ad_paths))

    if dev:
        _logger.warning("RUNNING IN DEVELOPMENT MODE")

    if debug:
        _logger.warning("RUNNING IN DEBUG MODE")
Example #5
0
    def __init__(self, conffile, buildout_dir, parse_config=True):
        self.buildout_dir = buildout_dir
        self.openerp_config_file = conffile

        self._registry = self.cr = None
        if parse_config:
            # Change to the parts/odoo directory to cover the case of relative
            # addons paths
            os.chdir(os.path.split(os.path.split(openerp.__file__)[0])[0])
            config.parse_config(['-c', conffile])
Example #6
0
 def __init__(self, args):
     path = session_path()
     self.session_store = FilesystemSessionStore(path)
     self.args = args
     init_logger()
     if args.config_file:
         logger.info("Load OpenERP config file")
         config.parse_config(['-c', args.conf_file])
     self.patch_all()
     databases = args.db
     if not databases:
         database = config.get('db_name', None)
         if not database:
             raise Exception("No database defined")
         databases = [database]
     else:
         databases = databases.split(',')
     self.load_databases(databases, maxcursor=int(args.maxcursor))
     for namespace in self.namespaces.keys():
         logger.info("Add namespace: %r", namespace)
Example #7
0
 def __init__(self, args):
     path = session_path()
     self.session_store = FilesystemSessionStore(path)
     self.args = args
     init_logger()
     if args.config_file:
         logger.info("Load OpenERP config file")
         config.parse_config(['-c', args.conf_file])
     self.patch_all()
     databases = args.db
     if not databases:
         database = config.get('db_name', None)
         if not database:
             raise Exception("No database defined")
         databases = [database]
     else:
         databases = databases.split(',')
     self.load_databases(databases, maxcursor=int(args.maxcursor))
     for namespace in self.namespaces.keys():
         logger.info("Add namespace: %r", namespace)
Example #8
0
                self.setproctitle(db_name)
                db = openerp.sql_db.db_connect(db_name)
                threading.current_thread().dbname = db_name
                with closing(db.cursor()) as cr:
                    self._work_database(cr)
            else:
                self.db_index = 0

    def sleep(self):
        # Really sleep once all the databases have been processed.
        if self.db_index == 0:
            interval = 15 + self.pid % self.multi.population  # chorus effect
            time.sleep(interval)

    def start(self):
        workers.Worker.start(self)


if __name__ == "__main__":
    args = sys.argv[1:]
    servercli.check_root_user()
    config.parse_config(args)

    servercli.check_postgres_user()
    openerp.netsvc.init_logger()
    servercli.report_configuration()

    openerp.multi_process = True
    openerp.worker_connector = True
    Multicornnector(openerp.service.wsgi_server.application).run([], False)
Example #9
0
from django.conf import settings
import sys, os
import warnings
warnings.filterwarnings("ignore", message="Old style callback, usecb_func(ok, store) instead")


ERP_PATH = settings.ERP_PATH
if not ERP_PATH in sys.path:
    sys.path.insert(0, os.path.dirname(ERP_PATH))

from openerp.tools import config
from openerp.modules import get_modules
from openerp.pooler import get_db_and_pool

# Configurar el server con los parametros adecuados.
config.parse_config(['-c', settings.ERP_CONF])

# Modulos en nuestra conf de OpenERP
get_modules()

DB, POOL = get_db_and_pool(settings.ERP_DB)

cursor = DB.cursor()

user_obj = POOL.get('res.users')


try:
    USER = user_obj.search(cursor, 1, [
            ('login', '=', settings.ERP_UN),
            ], limit=1)[0]
Example #10
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import xmlrpclib
import MySQLdb
import time
import string
import datetime
import re
from collections import defaultdict
from openerp.tools import config
start = time.time()

#Load config file
config.parse_config(['-c', '/etc/odoo/openerp-server.conf'])

username = config.get('weborder_user', False)  #the user
pwd = config.get('weborder_pwd', False)  #the password
dbname = config.get('weborder_db', False)  #the database

cnx = MySQLdb.connect(
    user=config.get('joomla_user', False),
    passwd=config.get('joomla_pwd', False),
    host=config.get('joomla_host', False),
    port=int(config.get('joomla_port', False)),
    db=config.get('joomla_db', False),
)

cursor = cnx.cursor()
cursor2 = cnx.cursor()
cursor3 = cnx.cursor()
Example #11
0
                self.setproctitle(db_name)
                db = openerp.sql_db.db_connect(db_name)
                threading.current_thread().dbname = db_name
                with closing(db.cursor()) as cr:
                    self._work_database(cr)
            else:
                self.db_index = 0

    def sleep(self):
        # Really sleep once all the databases have been processed.
        if self.db_index == 0:
            interval = 15 + self.pid % self.multi.population  # chorus effect
            time.sleep(interval)

    def start(self):
        workers.Worker.start(self)


if __name__ == "__main__":
    args = sys.argv[1:]
    servercli.check_root_user()
    config.parse_config(args)

    servercli.check_postgres_user()
    openerp.netsvc.init_logger()
    servercli.report_configuration()

    openerp.multi_process = True
    openerp.worker_connector = True
    Multicornnector(openerp.service.wsgi_server.application).run([], False)