Merge lp:~xavinsky/openerp/2bugfix-and-doc into lp:openerp

Proposed by xavinsky
Status: Needs review
Proposed branch: lp:~xavinsky/openerp/2bugfix-and-doc
Merge into: lp:openerp
Diff against target: 259 lines (+131/-40)
2 files modified
bzr_set.py (+85/-40)
test_bzr_set.py (+46/-0)
To merge this branch: bzr merge lp:~xavinsky/openerp/2bugfix-and-doc
Reviewer Review Type Date Requested Status
xavinsky (community) unit test ok (56 minutes) Approve
OpenERP Core Team Pending
Review via email: mp+78590@code.launchpad.net

Description of the change

  Bugs fix :
  - create the folder 'server/bin/addons/' if not exist
  - change repository client-web for version >= 6.0

  Messages fix :
  - old link inactive http://test.openobject.com
    changed by https://launchpad.net/openobject

  New :
  - add the repository doc : ~openerp-community/openobject-doc/<version>

  PEP8 :
  - compliance ok with py.test --pep8

  Unit test :
  - test install and upgrade for all version  Bugs fix :
  - create the folder 'server/bin/addons/' if not exist
  - change repository client-web for version >= 6.0

To post a comment you must log in.
Revision history for this message
xavinsky (xavinsky) wrote :
Download full text (9.2 KiB)

 ./test_bzr_set.py
Test Install Version 4.2
new branch of lp:~openerp-commiter/openobject-addons/4.2-extra-addons into /MYFOLDER/openerp/TestBzrSet/4.2/addons-extra
new branch of lp:~openerp/openobject-client-web/4.2 into /MYFOLDER/openerp/TestBzrSet/4.2/web
new branch of lp:~openerp-community/openobject-addons/trunk-addons-community into /MYFOLDER/openerp/TestBzrSet/4.2/addons-community
new branch of lp:~openerp/openobject-server/4.2 into /MYFOLDER/openerp/TestBzrSet/4.2/server
new branch of lp:~openerp/openobject-client/4.2 into /MYFOLDER/openerp/TestBzrSet/4.2/client
new branch of lp:~openerp-community/openobject-doc/5.0 into /MYFOLDER/openerp/TestBzrSet/4.2/doc
new branch of lp:~openerp/openobject-addons/4.2 into /MYFOLDER/openerp/TestBzrSet/4.2/addons
(Re)Computing Symbolic links...
===============================================================================
Sources of OpenERP have been installed. If you develop new features,
you can get more information on how to contribute to the project here:
 https://launchpad.net/openobject
===============================================================================
Duration : 2 minutes 40.22 secondes
Test Install Version 5.0
new branch of lp:~openerp-commiter/openobject-addons/stable_5.0-extra-addons into /MYFOLDER/openerp/TestBzrSet/5.0/addons-extra
new branch of lp:~openerp/openobject-client-web/5.0 into /MYFOLDER/openerp/TestBzrSet/5.0/web
new branch of lp:~openerp-community/openobject-addons/trunk-addons-community into /MYFOLDER/openerp/TestBzrSet/5.0/addons-community
new branch of lp:~openerp/openobject-server/5.0 into /MYFOLDER/openerp/TestBzrSet/5.0/server
new branch of lp:~openerp/openobject-client/5.0 into /MYFOLDER/openerp/TestBzrSet/5.0/client
new branch of lp:~openerp-community/openobject-doc/5.0 into /MYFOLDER/openerp/TestBzrSet/5.0/doc
new branch of lp:~openerp/openobject-addons/5.0 into /MYFOLDER/openerp/TestBzrSet/5.0/addons
(Re)Computing Symbolic links...
===============================================================================
Sources of OpenERP have been installed. If you develop new features,
you can get more information on how to contribute to the project here:
 https://launchpad.net/openobject
===============================================================================
Duration : 7 minutes 40.60 secondes
Test Install Version 6.0
new branch of lp:~openerp-commiter/openobject-addons/extra-6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/addons-extra
new branch of lp:~openerp/openobject-client-web/6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/web
new branch of lp:~openerp-community/openobject-addons/trunk-addons-community into /MYFOLDER/openerp/TestBzrSet/6.0/addons-community
new branch of lp:~openerp/openobject-server/6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/server
new branch of lp:~openerp/openobject-client/6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/client
new branch of lp:~openerp-community/openobject-doc/6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/doc
new branch of lp:~openerp/openobject-addons/6.0 into /MYFOLDER/openerp/TestBzrSet/6.0/addons
(Re)Computing Symbolic links...
===============================================================================
Sources of Open...

Read more...

review: Approve (unit test ok (56 minutes))

Unmerged revisions

42. By xavinsky

Fix Message :
old link inactive http://test.openobject.com
changed by https://launchpad.net/openobject

41. By xavinsky

UnitTest : add test install and upgrade all version with bzr_set
Note : this test is a very long test : near 40 minutes with good connexion.

40. By xavinsky

fix : use dest_dir for create addons folders.

39. By xavinsky

add pep8 complaince
bug fix create folder before bzr

38. By xavinsky

Bugs fix :
- create the folder 'server/bin/addons/' if not exist
- change repository client-web for version >= 6.0

New :
- add the repository doc : ~openerp-community/openobject-doc/<version>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzr_set.py'
2--- bzr_set.py 2011-03-07 10:59:15 +0000
3+++ bzr_set.py 2011-10-07 13:03:45 +0000
4@@ -2,23 +2,16 @@
5
6 __all__ = ['update_openerp']
7
8+
9 import os
10-import shutil
11-import glob
12 import bzrlib.builtins
13+from shutil import rmtree
14+from glob import glob
15 from bzrlib.plugins import launchpad
16 from bzrlib.branch import Branch
17 from bzrlib.errors import NotBranchError
18 from bzrlib.revisionspec import RevisionSpec
19
20-def run_cmd(cmdname, *args, **kwargs):
21- f = getattr(bzrlib.builtins, 'cmd_' + cmdname)()
22- if hasattr(f, '_setup_outf'):
23- # old versions of bzr does not have this function
24- # this function must be called to avoid a exception in bzr code
25- f._setup_outf()
26- return f.run(*args, **kwargs)
27-
28 _VERSIONS = ('4.2', '5.0', '6.0', 'trunk')
29 _DEFAULT_VERSION = '6.0'
30 _EXTRA_ADDONS_MAP = {
31@@ -28,10 +21,21 @@
32 'trunk': 'trunk-extra-addons',
33 }
34
35-def update_openerp(dest_dir, version=_DEFAULT_VERSION, lplogin=None, export=False, revision=None, verbose=False):
36+
37+def run_cmd(cmdname, *args, **kwargs):
38+ f = getattr(bzrlib.builtins, 'cmd_' + cmdname)()
39+ if hasattr(f, '_setup_outf'):
40+ # old versions of bzr does not have this function
41+ # this function must be called to avoid a exception in bzr code
42+ f._setup_outf()
43+ return f.run(*args, **kwargs)
44+
45+
46+def update_openerp(dest_dir, version=_DEFAULT_VERSION, lplogin=None,
47+ export=False, revision=None, verbose=False):
48 """
49 if lplogin == None -> make a branch instead of a checkout
50- if export == True -> bzr export
51+ if export == True -> bzr export
52 if revision is provided, get the branches at this revision
53 more information with:
54 $> bzr help revisionspec
55@@ -59,10 +63,30 @@
56 'server': (BASEURL + '~openerp/openobject-server/' + version, True),
57 'client': (BASEURL + '~openerp/openobject-client/' + version, True),
58 'addons': (BASEURL + '~openerp/openobject-addons/' + version, True),
59- 'addons-extra': (BASEURL + '~openerp-commiter/openobject-addons/' + extraversion, False),
60- 'addons-community': (BASEURL + '~openerp-community/openobject-addons/' + communityversion + '-addons-community', False),
61- 'web': (BASEURL + '~openerp/openobject-client-web/' + webversion, True),
62+ 'addons-extra': (BASEURL + '~openerp-commiter/openobject-addons/' +
63+ extraversion, False),
64+ 'addons-community': (BASEURL +
65+ '~openerp-community/openobject-addons/' +
66+ communityversion + '-addons-community', False),
67 }
68+ if version in ('4.2', '5.0', '6.0'):
69+ bzr_repository['web'] = (BASEURL + '~openerp/openobject-client-web/' +
70+ version, True)
71+ else:
72+ bzr_repository['web'] = (BASEURL + '~openerp/openerp-web/' + version,
73+ True)
74+
75+ if version in ('4.2', '5.0'):
76+ bzr_repository['doc'] = (BASEURL +
77+ '~openerp-community/openobject-doc/5.0', True)
78+ elif version in ('6.0', ):
79+ bzr_repository['doc'] = (BASEURL +
80+ '~openerp-community/openobject-doc/6.0', True)
81+ elif version in ('trunk',):
82+ bzr_repository['doc'] = (BASEURL +
83+ '~openerp-community/openobject-doc/6.1', True)
84+
85+ bzr_folders_links = ['server/bin/addons/', ]
86
87 bzr_links = {
88 'addons/*': 'server/bin/addons/',
89@@ -70,11 +94,14 @@
90
91 if branch:
92 cmd = {'new': lambda u, l, r: run_cmd('branch', u, l, revision=r),
93- 'update': lambda u, l, r: run_cmd('pull', u, directory=l, overwrite=True, revision=r),
94+ 'update': lambda u, l, r: run_cmd('pull', u, directory=l,
95+ overwrite=True, revision=r),
96 }
97 else:
98- cmd = {'new': lambda u, l, r: run_cmd('checkout', u, l, lightweight=True, revision=r),
99- 'update': lambda u, l, r: run_cmd('update', l), # no revision option :(
100+ cmd = {'new': lambda u, l, r: run_cmd('checkout', u, l,
101+ lightweight=True, revision=r),
102+ # no revision option for update :(
103+ 'update': lambda u, l, r: run_cmd('update', l),
104 }
105 cmd['export'] = lambda u, l, r: run_cmd('export', l, u, revision=r)
106
107@@ -88,17 +115,18 @@
108 typ = ['checkout', 'branch'][branch]
109 if export:
110 if os.path.exists(local):
111- shutil.rmtree(local)
112+ rmtree(local)
113 status = 'export'
114 typ = 'sources'
115 else:
116 try:
117 b = Branch.open(local)
118- # FIXME check that the current workingDirectory is a branch or a checkout
119+ # FIXME check that the current workingDirectory is a branch or
120+ # a checkout
121 status = 'update'
122 except NotBranchError:
123 status = 'new'
124-
125+
126 frm = bzrdir
127 rev = None
128 if revision and (not revision.startswith('tag:') or has_tags):
129@@ -106,24 +134,30 @@
130 rev = RevisionSpec.from_string(revision)
131
132 log(msg % {'status': status, 'type': typ, 'to': local, 'from': frm})
133-
134+
135 cmd[status](bzrdir, local, rev and [rev] or None)
136
137+ for folder_links in bzr_folders_links:
138+ if not os.path.exists(os.path.join(dest_dir, folder_links)):
139+ os.makedirs(os.path.join(dest_dir, folder_links))
140+
141 # Doing symlinks
142 log('(Re)Computing Symbolic links...')
143- for src2,dest2 in bzr_links.items():
144+ for src2, dest2 in bzr_links.items():
145 src2 = os.path.join(dest_dir, src2)
146 dest2 = os.path.join(dest_dir, dest2)
147- for src in glob.glob(src2):
148+ for src in glob(src2):
149 dest = os.path.join(dest2, os.path.basename(src))
150 if not os.path.isdir(dest):
151 os.symlink(os.path.realpath(src), dest)
152
153- log('='*79)
154- log('Sources of OpenERP have been installed. If you develop new features,')
155- log('you can get more information on how to contribute to the project here:')
156- log('\thttp://test.openobject.com')
157- log('='*79)
158+ log('=' * 79)
159+ log('Sources of OpenERP have been installed. ' +
160+ 'If you develop new features,')
161+ log('you can get more information on how to ' +
162+ 'contribute to the project here:')
163+ log('\thttps://launchpad.net/openobject')
164+ log('=' * 79)
165
166 #
167 # Testing bzr send
168@@ -131,18 +165,29 @@
169
170 if __name__ == '__main__':
171 import optparse
172- description = """Tool that allows you to get the last sources of openerp on launchpad.
173-It downloads all branches, and create symlinks for addons in the server. By
174-default, it loads the latest stable version.
175+ description = """Tool that allows you to get the last sources of openerp on
176+launchpad. It downloads all branches, and create symlinks for addons in the
177+server. By default, it loads the latest stable version.
178 """
179- parser = optparse.OptionParser(description=description,
180+ parser = optparse.OptionParser(description=description,
181 usage="%prog [options] [directory]")
182- parser.add_option('--checkout', dest='lplogin', help="Specify the launchpad login to make a checkout instead of a branch")
183- parser.add_option('--export', dest='export', help='Make an export of the sources, instead of branches', action='store_true', default=False)
184- parser.add_option('-v', dest="version", default=_DEFAULT_VERSION, type="choice", choices=_VERSIONS, help="Specify the version to take (trunk, 4.2, 5.0, 6.0)")
185- parser.add_option('-r', dest="revision", default=None, help="Specify the revision to take. (useful to take a specific TAG or to specify a DATE)")
186- parser.add_option('-q', '--quiet', dest='quiet', help='Suppress the output', action='store_true', default=False)
187+ parser.add_option('--checkout', dest='lplogin',
188+ help="Specify the launchpad login to make a checkout " +
189+ "instead of a branch")
190+ parser.add_option('--export', dest='export',
191+ help='Make an export of the sources, instead of ' +
192+ 'branches', action='store_true', default=False)
193+ parser.add_option('-v', dest="version", default=_DEFAULT_VERSION,
194+ type="choice", choices=_VERSIONS,
195+ help="Specify the version to take " +
196+ "(trunk, 4.2, 5.0, 6.0)")
197+ parser.add_option('-r', dest="revision", default=None,
198+ help="Specify the revision to take. (useful to take a " +
199+ "specific TAG or to specify a DATE)")
200+ parser.add_option('-q', '--quiet', dest='quiet',
201+ help='Suppress the output', action='store_true',
202+ default=False)
203 opt, args = parser.parse_args()
204 dest_dir = args and args[0] or '.'
205- update_openerp(dest_dir, opt.version, opt.lplogin, opt.export, opt.revision, not opt.quiet)
206-
207+ update_openerp(dest_dir, opt.version, opt.lplogin, opt.export,
208+ opt.revision, not opt.quiet)
209
210=== added file 'test_bzr_set.py'
211--- test_bzr_set.py 1970-01-01 00:00:00 +0000
212+++ test_bzr_set.py 2011-10-07 13:03:45 +0000
213@@ -0,0 +1,46 @@
214+#!/usr/bin/env python
215+import unittest
216+
217+from os import getcwd
218+from os.path import exists
219+from shutil import rmtree
220+from time import time
221+
222+from bzr_set import _VERSIONS, update_openerp
223+
224+
225+class TestBzrSet(unittest.TestCase):
226+
227+ def setUp(self):
228+ self.path = getcwd() + "/TestBzrSet/"
229+
230+ def test_install_and_update(self):
231+ """ Test install and update all version with verbose
232+ """
233+
234+ if exists(self.path):
235+ rmtree(self.path)
236+
237+ # test install
238+ for version in _VERSIONS:
239+ print "Test Install Version %s " % version
240+ dest_dir = self.path + version
241+ time_start = time()
242+ update_openerp(dest_dir, version, verbose=True)
243+ time_duration = time() - time_start
244+ print "Duration : %s minutes %2.2f secondes " % \
245+ (int(float(time_duration) / 60), (float(time_duration) % 60))
246+ # test update
247+ for version in _VERSIONS:
248+ print "Test Update Version %s " % version
249+ dest_dir = self.path + version
250+ time_start = time()
251+ update_openerp(dest_dir, version, verbose=True)
252+ time_duration = time() - time_start
253+ print "Duration : %2.2f secondes " % (float(time_duration) % 60)
254+
255+ rmtree(self.path)
256+
257+
258+if __name__ == '__main__':
259+ unittest.main()