Merge lp:~xavinsky/openerp-web/trunk-web-xma into lp:openerp-web

Proposed by xavinsky
Status: Merged
Approved by: Xavier (Open ERP)
Approved revision: 1346
Merged at revision: 1357
Proposed branch: lp:~xavinsky/openerp-web/trunk-web-xma
Merge into: lp:openerp-web
Diff against target: 110 lines (+36/-19)
2 files modified
openerp-web (+33/-9)
setup.py (+3/-10)
To merge this branch: bzr merge lp:~xavinsky/openerp-web/trunk-web-xma
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Approve
Review via email: mp+80230@code.launchpad.net

Description of the change

  Installation openerp with

python setup.py install
In Debian wheezy didn't works for a lot of details.
I tried to fix it with this branch.

fix 1 : packages list with find_packages() in setup.py
Bug : 876308

fix 2 : script name error : scripts=['openerp-web']

rename 1 : openerp-web.py => openerp-web
for coherence script name (openerp-server openerp-client)

fix 3 : default missing options.log_config in openerp-web

fix 4 : change sys.path.insert with addons path.

  First try merge in another branch was review by Xavier.
In this new branch I try to fix better the problems.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Merging it with just two small modifications:

* Removed the first `raise`, I'll let the second one handle the error
* Used `OptionParser.error`[0] instead of a string raise, as I'm not fond of string raises and it seemed a better fit

Thanks.

[0] http://docs.python.org/library/optparse.html#how-optparse-handles-errors

review: Approve
Revision history for this message
xavinsky (xavinsky) wrote :

Hi Xavier.

  Thanks for merged it.
What about this branch now.
I can remove it ?

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

No need, Launchpad marked it as merged, so it's not visible from the main view. It can stay for historical purposes, we leave ours there, they don't bother anybody.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'openerp-web.py' => 'openerp-web'
2--- openerp-web.py 2011-10-05 17:58:26 +0000
3+++ openerp-web 2011-10-24 15:46:23 +0000
4@@ -10,11 +10,6 @@
5 import werkzeug.serving
6 import werkzeug.contrib.fixers
7
8-path_root = os.path.dirname(os.path.abspath(__file__))
9-path_addons = os.path.join(path_root, 'addons')
10-if path_addons not in sys.path:
11- sys.path.insert(0, path_addons)
12-
13 optparser = optparse.OptionParser()
14 optparser.add_option("-s", "--session-path", dest="session_storage",
15 default=os.path.join(tempfile.gettempdir(), "oe-sessions"),
16@@ -25,7 +20,7 @@
17 help="OpenERP server port", type="int", metavar="NUMBER")
18 optparser.add_option("--db-filter", dest="dbfilter", default='.*',
19 help="Filter listed database", metavar="REGEXP")
20-optparser.add_option('--addons-path', dest='addons_path', default=[path_addons], action='append',
21+optparser.add_option('--addons-path', dest='addons_path', default=[], action='append',
22 help="Path do addons directory", metavar="PATH")
23 optparser.add_option('--load', dest='server_wide_modules', default=['web'], action='append',
24 help="Load a additional module before login (by default only 'web' is loaded)", metavar="MODULE")
25@@ -55,15 +50,44 @@
26 help="Logging configuration file", metavar="FILE")
27 optparser.add_option_group(logging_opts)
28
29-import web.common.http
30
31 if __name__ == "__main__":
32 (options, args) = optparser.parse_args(sys.argv[1:])
33+
34+ if not options.addons_path:
35+ path_root = os.path.dirname(os.path.abspath(__file__))
36+ path_addons = os.path.join(path_root, 'addons')
37+ if os.path.exists(path_addons):
38+ options.addons_path.append(path_addons)
39+
40+ def remove_end_slash(text):
41+ if text[-1] in '/\\':
42+ return text[:-1]
43+ return text
44+
45+ def drop_false_path(path):
46+ if os.path.exists(path):
47+ return True
48+
49+ options.addons_path = map(remove_end_slash, options.addons_path)
50+ options.addons_path = filter(drop_false_path, options.addons_path)
51+
52+ if not options.addons_path:
53+ raise('Error Importing web modules. Missing or incorrect --addons-path ')
54+
55+ for path_addons in options.addons_path:
56+ if path_addons not in sys.path:
57+ sys.path.insert(0, path_addons)
58+
59+ try:
60+ import web.common.http
61+ except:
62+ raise('Error Importing web modules. addons_path must be wrong.')
63+
64 options.backend = 'xmlrpc'
65-
66 os.environ["TZ"] = "UTC"
67
68- if sys.version_info >= (2, 7):
69+ if sys.version_info >= (2, 7) and os.path.exists(options.log_config):
70 with open(options.log_config) as file:
71 dct = json.load(file)
72 logging.config.dictConfig(dct)
73
74=== modified file 'setup.py'
75--- setup.py 2011-09-13 07:12:05 +0000
76+++ setup.py 2011-10-24 15:46:23 +0000
77@@ -2,7 +2,7 @@
78 import os
79 import re
80 import sys
81-from setuptools import setup
82+from setuptools import setup, find_packages
83
84 execfile('addons/web/common/release.py')
85
86@@ -57,14 +57,7 @@
87 ],
88 test_suite = 'unittest2.collector',
89 zip_safe=False,
90- packages=[
91- 'addons',
92- 'addons.base',
93- 'addons.base.controllers',
94- 'addons.base_calendar',
95- 'addons.base_hello',
96- 'openerpweb',
97- ],
98+ packages=find_packages(),
99 classifiers=[
100 'Development Status :: 6 - Production/Stable',
101 'Operating System :: OS Independent',
102@@ -72,7 +65,7 @@
103 'Environment :: Web Environment',
104 'Topic :: Office/Business :: Financial',
105 ],
106- scripts=['scripts/openerp-web'],
107+ scripts=['openerp-web'],
108 data_files=(find_data_files('addons')
109 + opts.pop('data_files', [])
110 ),