[7.0] Ubuntu 13.10 Conflict with python package "resource"

Bug #1256199 reported by Nhomar - Vauxoo
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Undecided
OpenERP Publisher's Warranty Team
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned
OpenERP Community Backports (Addons)
Status tracked in 7.0
7.0
New
Undecided
Unassigned
OpenERP Community Backports (Server)
Status tracked in 7.0
7.0
New
Undecided
Unassigned

Bug Description

Hello.

RUn openerp 7.0 on Ubuntu 13.10.

2013-11-29 05:04:54,408 23539 WARNING ? openerp.modules.module:
Ambiguous import: the OpenERP module `resource` is shadowed by another
module (available at /usr/lib/python2.7/lib-dynload/resource.x86_64-linux-gnu.so).
To import it, use `import openerp.addons.<module>.`.

It only appear with "workers"

I tried to patch with:

=== modified file 'resource/__init__.py'
--- resource/__init__.py 2011-01-14 00:11:01 +0000
+++ resource/__init__.py 2013-11-29 05:04:23 +0000
@@ -19,8 +19,8 @@
 #
 ##############################################################################

-import resource
-import faces
+from . import resource
+from . import faces

 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'resource/faces/__init__.py'
--- resource/faces/__init__.py 2011-01-14 00:11:01 +0000
+++ resource/faces/__init__.py 2013-11-29 04:57:46 +0000
@@ -25,6 +25,6 @@
     STRICT, SLOPPY, SMART, Multi, YearlyMax, WeeklyMax, MonthlyMax, \
     DailyMax, VariableLoad

-from resource import Resource
+from .resource import Resource

 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'resource/faces/task.py'
--- resource/faces/task.py 2013-05-14 14:28:37 +0000
+++ resource/faces/task.py 2013-11-29 05:04:52 +0000
@@ -33,7 +33,7 @@
 #@<< Imports >>
 #@+node:<< Imports >>
 import pcalendar
-import resource
+from . import resource
 import types
 import sys
 import datetime

But the message still appear.

I made an rgrep on addons and "resource" is only there:

./project_long_term/project_long_term.py:25:from openerp.addons.resource.faces import task as Task
./resource/__init__.py:22:import resource
./resource/faces/task.py:36:import resource
./resource/faces/__init__.py:28:from resource import Resource
./project/project.py:32:from openerp.addons.resource.faces import task as Task
./project/project.py:455: result = "from openerp.addons.resource.faces import *\n"

The module: resource/ should be called in a more particular way (for v8.0) but for this version it is really painfull have this kind of warnings in an stable version I think.

It is not happening in Trunk.

Tags: maintenance

Related branches

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

FYI:

"resource" is an official python package.

http://docs.python.org/library/resource

Regards.

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Changed in openobject-addons:
status: New → Confirmed
Revision history for this message
Med Said BARA (diassynthesis) wrote :

Hi;
I am also facing this situation, but it's just a WARNING.
Extarct from my log file:
2014-02-04 22:57:23,080 1683 INFO ? openerp: OpenERP version 7.0-20140204-002725
2014-02-04 22:57:23,085 1683 INFO ? openerp: addons paths: /usr/lib/pymodules/python2.7/openerp/addons
2014-02-04 22:57:23,085 1683 INFO ? openerp: database hostname: localhost
2014-02-04 22:57:23,087 1683 INFO ? openerp: database port: 5432
2014-02-04 22:57:23,087 1683 INFO ? openerp: database user: openerp
2014-02-04 22:57:23,106 1683 WARNING ? openerp.modules.module:
Ambiguous import: the OpenERP module `resource` is shadowed by another
module (available at /usr/lib/python2.7/lib-dynload/resource.so).
To import it, use `import openerp.addons.<module>.`.
2014-02-04 22:57:23,323 1948 INFO ? openerp.service.workers: Worker WorkerHTTP (1948) alive
2014-02-04 22:57:23,453 1952 INFO ? openerp.service.workers: Worker WorkerHTTP (1952) alive
2014-02-04 22:57:23,493 1958 INFO ? openerp.service.workers: Worker WorkerHTTP (1958) alive

As stated by Nhomar "resource" is a python standard library, and is dynamicaly loaded if it is in " ../pythonx.x/lib-dynload/ " directory (so that they can be loaded dynamically (at run time) into the interpreter), and Dynamically loaded extension modules loaded by Python are not unloaded.

So, i think this case is dealing with a relative import:
In many __init__.py files (under addons) we can find an " import resource" statement with a "resource.py" files in the same directory, and in this case it seems to me that the solution is to replace the "import" statement by " from openerp.addons.xxxxx import resource".

http://docs.python.org/2/c-api/init.html?highlight=dynamically%20loaded%20extension
http://www.python.org/dev/peps/pep-0302/
http://docs.python.org/2/reference/simple_stmts.html#import

But i'm not sure this is the solution (if someone else can investigate and confirm !!!).

Best regards

Revision history for this message
Med Said BARA (diassynthesis) wrote :

In my installation, i can find " import resource" also under:

addons/project_resource_load/__init__.py
addons/hr_attendance_analysis/__init__.py
addons/project_resource_load/__init__.py
project_execution_control/__init__.py

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

Tagged "maintenance" but no public patch or branch attached.
I made my own OWP demand, I'll post their patch eventually.

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

The branches attached seem to work, is it worth merging them in OCB ?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.