# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1533032902 -7200 # Tue Jul 31 12:28:22 2018 +0200 # Node ID d4a964711550af3030c0bfe32e25fa930180e7ab # Parent 89126f315e0647c0ca999fc2291c8cce12eddf7c :pencil: use _logger instead of logging (no point in defining it otherwise) diff --git a/do_tests.py b/do_tests.py --- a/do_tests.py +++ b/do_tests.py @@ -170,7 +170,7 @@ c = configparser.ConfigParser() if not os.path.exists(setup_path): - logging.fatal('Missing %s', setup_path) + _logger.fatal('Missing %s', setup_path) return 12 c.read(setup_path) @@ -192,13 +192,13 @@ c.has_option('odoo_scripts', 'postgresql_version') and c.get('odoo_scripts', 'postgresql_version')) or '9.6' image = "%s/%s:latest" % (registry, project) - logging.debug("Docker image: %s", image) + _logger.debug("Docker image: %s", image) # read from odoo.conf if it exists sample_conf = 'conf/dev/odoo.conf' if os.path.exists(sample_conf): - logging.info('Reading from sample configuration %s', sample_conf) + _logger.info('Reading from sample configuration %s', sample_conf) c.read(sample_conf) if not odoo_db_user: if c.has_option('options', 'db_user'): @@ -220,7 +220,7 @@ ): extensions.append('unaccent') else: - logging.debug('No sample configuration %s', sample_conf) + _logger.debug('No sample configuration %s', sample_conf) extensions.append('unaccent') # Do stuff diff --git a/docker_dev_start.py b/docker_dev_start.py --- a/docker_dev_start.py +++ b/docker_dev_start.py @@ -60,10 +60,10 @@ """Run flake8 if found """ if which('flake8'): - logging.info('Running flake8') + _logger.info('Running flake8') call(['flake8']) else: - logging.warning('No flake8 in PATH') + _logger.warning('No flake8 in PATH') def main(argv=None): # IGNORE:C0111 @@ -280,12 +280,12 @@ if restore_filename: if not database: - logging.fatal('No database name given for restore') + _logger.fatal('No database name given for restore') return 13 c = ConfigParser() if not os.path.exists(setup_path): - logging.fatal('Missing %s', setup_path) + _logger.fatal('Missing %s', setup_path) return 12 c.read(setup_path) @@ -293,7 +293,7 @@ if c.has_option('odoo_scripts', 'modules'): for entry in c.get('odoo_scripts', 'modules').split(): modules.extend(glob.glob(entry)) - logging.debug("addon modules: %s", modules) + _logger.debug("addon modules: %s", modules) registry = ( c.has_section('odoo_scripts') and @@ -312,16 +312,16 @@ c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'postgresql_version') and c.get('odoo_scripts', 'postgresql_version')) or '9.6' - logging.debug("Docker image: %s", image) + _logger.debug("Docker image: %s", image) # detect if docker image already exists docker_client = docker_api(base_url='unix://var/run/docker.sock') image_list = docker_client.images(name=image, quiet=True) if not image_list: - logging.info("Image %s does not exist", image) + _logger.info("Image %s does not exist", image) else: - logging.info("Image %s exists", image) + _logger.info("Image %s exists", image) if (not image_list and not nmspc.no_build) or nmspc.force_build: - logging.info("Building image %s", image) + _logger.info("Building image %s", image) import docker_build arguments = [ '--dev' @@ -416,11 +416,11 @@ if addresses: local_ip = addresses[0] except ImportError: - logging.warn("Consider installing python netifaces" + _logger.warn("Consider installing python netifaces" " to ease local IP detection") if not local_ip: import socket - logging.info('Contacting Google Public DNS to find our IP') + _logger.info('Contacting Google Public DNS to find our IP') local_ip = [ ( s.connect(('8.8.8.8', 53)), @@ -430,7 +430,7 @@ socket.socket(socket.AF_INET, socket.SOCK_DGRAM)] ][0][1] - logging.debug('IP found %s', local_ip) + _logger.debug('IP found %s', local_ip) arg.append('--db_host') arg.append(local_ip) @@ -445,7 +445,7 @@ user = db_user password = db_password if os.path.isfile(local_conf_path): - logging.info('Local configuration file found: %s' % local_conf_path) + _logger.info('Local configuration file found: %s' % local_conf_path) binds.append('%s:/opt/odoo/etc' % os.path.join( project_path, local_conf_dir)) cp_local = ConfigParser() @@ -466,7 +466,7 @@ # data volume handling if odoo_type != 'odoo7': data_volume_name = '{}_data'.format(project_name) - logging.debug('Using data volume %s', data_volume_name) + _logger.debug('Using data volume %s', data_volume_name) createVolume(docker_client, data_volume_name) # make sure the permission in the volume are correct mount_opts = '{}:/mnt/data'.format(data_volume_name) @@ -479,7 +479,7 @@ binds.append('{}:/mnt/data'.format(data_volume_name)) arg.append('--data-dir /mnt/data') else: - logging.debug('No data volume for this odoo version') + _logger.debug('No data volume for this odoo version') # avoid the duplication of unbind volumes with all addons # additionnal_addons only in odoo < 10 @@ -518,9 +518,9 @@ except OperationalError as exception: if nmspc.create_user: - logging.debug('Cannot connect to database with user %s', user) - logging.debug(exception) - logging.info('Creating user %s', user) + _logger.debug('Cannot connect to database with user %s', user) + _logger.debug(exception) + _logger.info('Creating user %s', user) if start_postgresql: connection = connect( user='pg', @@ -540,38 +540,38 @@ connection.commit() connection.close() else: - logging.fatal( + _logger.fatal( 'Cannot connect to database with user %s', user) - logging.fatal(exception) - logging.info( + _logger.fatal(exception) + _logger.info( "You can add the --create-user argument to create it") return 16 # restore if restore_filename: restore_basename = os.path.basename(restore_filename) - logging.info("Copying dump file in docker") + _logger.info("Copying dump file in docker") call([ 'docker', 'cp', restore_filename, '{}:/tmp/{}'.format(name, restore_basename)]) - logging.info("Creating database") + _logger.info("Creating database") call([ 'docker', 'exec', name, 'createdb', '-U', user, database]) - logging.info("Restoring database") + _logger.info("Restoring database") restore = call([ 'docker', 'exec', name, 'pg_restore', '-U', user, '-O', '-d', database, '/tmp/{}'.format(restore_basename)]) if not restore: return 15 - logging.info("Removing dump file in docker") + _logger.info("Removing dump file in docker") call(['docker', 'exec', name, '/tmp/{}'.format(restore_basename)]) if not start_postgresql and not odoo_help and restore_filename: - logging.info("Creating database %s", database) + _logger.info("Creating database %s", database) createdb = call([ 'createdb', '-U', user, database]) if not createdb: return 17 - logging.info("Restoring database %s", database) + _logger.info("Restoring database %s", database) restore = call([ 'pg_restore', '-U', user, '-O', '-d', database, restore_filename]) @@ -614,7 +614,7 @@ cmd.extend(options) cmd.append(image) cmd.extend(arg) - logging.debug(' '.join(cmd)) + _logger.debug(' '.join(cmd)) result = call(cmd) return result @@ -624,10 +624,10 @@ """ volumes = docker_client.volumes(filters={'name': data_volume_name}) if volumes['Volumes']: - logging.debug('Volume %s already exist', data_volume_name) + _logger.debug('Volume %s already exist', data_volume_name) return volumes['Volumes'][0] else: - logging.debug('Creating volume %s', data_volume_name) + _logger.debug('Creating volume %s', data_volume_name) return docker_client.create_volume(name=data_volume_name)