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
=== modified file 'bzr_set.py'
--- bzr_set.py 2011-03-07 10:59:15 +0000
+++ bzr_set.py 2011-10-07 13:03:45 +0000
@@ -2,23 +2,16 @@
22
3__all__ = ['update_openerp']3__all__ = ['update_openerp']
44
5
5import os6import os
6import shutil
7import glob
8import bzrlib.builtins7import bzrlib.builtins
8from shutil import rmtree
9from glob import glob
9from bzrlib.plugins import launchpad10from bzrlib.plugins import launchpad
10from bzrlib.branch import Branch11from bzrlib.branch import Branch
11from bzrlib.errors import NotBranchError12from bzrlib.errors import NotBranchError
12from bzrlib.revisionspec import RevisionSpec13from bzrlib.revisionspec import RevisionSpec
1314
14def run_cmd(cmdname, *args, **kwargs):
15 f = getattr(bzrlib.builtins, 'cmd_' + cmdname)()
16 if hasattr(f, '_setup_outf'):
17 # old versions of bzr does not have this function
18 # this function must be called to avoid a exception in bzr code
19 f._setup_outf()
20 return f.run(*args, **kwargs)
21
22_VERSIONS = ('4.2', '5.0', '6.0', 'trunk')15_VERSIONS = ('4.2', '5.0', '6.0', 'trunk')
23_DEFAULT_VERSION = '6.0'16_DEFAULT_VERSION = '6.0'
24_EXTRA_ADDONS_MAP = {17_EXTRA_ADDONS_MAP = {
@@ -28,10 +21,21 @@
28 'trunk': 'trunk-extra-addons',21 'trunk': 'trunk-extra-addons',
29}22}
3023
31def update_openerp(dest_dir, version=_DEFAULT_VERSION, lplogin=None, export=False, revision=None, verbose=False):24
25def run_cmd(cmdname, *args, **kwargs):
26 f = getattr(bzrlib.builtins, 'cmd_' + cmdname)()
27 if hasattr(f, '_setup_outf'):
28 # old versions of bzr does not have this function
29 # this function must be called to avoid a exception in bzr code
30 f._setup_outf()
31 return f.run(*args, **kwargs)
32
33
34def update_openerp(dest_dir, version=_DEFAULT_VERSION, lplogin=None,
35 export=False, revision=None, verbose=False):
32 """36 """
33 if lplogin == None -> make a branch instead of a checkout37 if lplogin == None -> make a branch instead of a checkout
34 if export == True -> bzr export 38 if export == True -> bzr export
35 if revision is provided, get the branches at this revision39 if revision is provided, get the branches at this revision
36 more information with:40 more information with:
37 $> bzr help revisionspec41 $> bzr help revisionspec
@@ -59,10 +63,30 @@
59 'server': (BASEURL + '~openerp/openobject-server/' + version, True),63 'server': (BASEURL + '~openerp/openobject-server/' + version, True),
60 'client': (BASEURL + '~openerp/openobject-client/' + version, True),64 'client': (BASEURL + '~openerp/openobject-client/' + version, True),
61 'addons': (BASEURL + '~openerp/openobject-addons/' + version, True),65 'addons': (BASEURL + '~openerp/openobject-addons/' + version, True),
62 'addons-extra': (BASEURL + '~openerp-commiter/openobject-addons/' + extraversion, False),66 'addons-extra': (BASEURL + '~openerp-commiter/openobject-addons/' +
63 'addons-community': (BASEURL + '~openerp-community/openobject-addons/' + communityversion + '-addons-community', False),67 extraversion, False),
64 'web': (BASEURL + '~openerp/openobject-client-web/' + webversion, True),68 'addons-community': (BASEURL +
69 '~openerp-community/openobject-addons/' +
70 communityversion + '-addons-community', False),
65 }71 }
72 if version in ('4.2', '5.0', '6.0'):
73 bzr_repository['web'] = (BASEURL + '~openerp/openobject-client-web/' +
74 version, True)
75 else:
76 bzr_repository['web'] = (BASEURL + '~openerp/openerp-web/' + version,
77 True)
78
79 if version in ('4.2', '5.0'):
80 bzr_repository['doc'] = (BASEURL +
81 '~openerp-community/openobject-doc/5.0', True)
82 elif version in ('6.0', ):
83 bzr_repository['doc'] = (BASEURL +
84 '~openerp-community/openobject-doc/6.0', True)
85 elif version in ('trunk',):
86 bzr_repository['doc'] = (BASEURL +
87 '~openerp-community/openobject-doc/6.1', True)
88
89 bzr_folders_links = ['server/bin/addons/', ]
6690
67 bzr_links = {91 bzr_links = {
68 'addons/*': 'server/bin/addons/',92 'addons/*': 'server/bin/addons/',
@@ -70,11 +94,14 @@
7094
71 if branch:95 if branch:
72 cmd = {'new': lambda u, l, r: run_cmd('branch', u, l, revision=r),96 cmd = {'new': lambda u, l, r: run_cmd('branch', u, l, revision=r),
73 'update': lambda u, l, r: run_cmd('pull', u, directory=l, overwrite=True, revision=r),97 'update': lambda u, l, r: run_cmd('pull', u, directory=l,
98 overwrite=True, revision=r),
74 }99 }
75 else:100 else:
76 cmd = {'new': lambda u, l, r: run_cmd('checkout', u, l, lightweight=True, revision=r),101 cmd = {'new': lambda u, l, r: run_cmd('checkout', u, l,
77 'update': lambda u, l, r: run_cmd('update', l), # no revision option :(102 lightweight=True, revision=r),
103 # no revision option for update :(
104 'update': lambda u, l, r: run_cmd('update', l),
78 }105 }
79 cmd['export'] = lambda u, l, r: run_cmd('export', l, u, revision=r)106 cmd['export'] = lambda u, l, r: run_cmd('export', l, u, revision=r)
80107
@@ -88,17 +115,18 @@
88 typ = ['checkout', 'branch'][branch]115 typ = ['checkout', 'branch'][branch]
89 if export:116 if export:
90 if os.path.exists(local):117 if os.path.exists(local):
91 shutil.rmtree(local)118 rmtree(local)
92 status = 'export'119 status = 'export'
93 typ = 'sources'120 typ = 'sources'
94 else:121 else:
95 try:122 try:
96 b = Branch.open(local)123 b = Branch.open(local)
97 # FIXME check that the current workingDirectory is a branch or a checkout124 # FIXME check that the current workingDirectory is a branch or
125 # a checkout
98 status = 'update'126 status = 'update'
99 except NotBranchError:127 except NotBranchError:
100 status = 'new'128 status = 'new'
101 129
102 frm = bzrdir130 frm = bzrdir
103 rev = None131 rev = None
104 if revision and (not revision.startswith('tag:') or has_tags):132 if revision and (not revision.startswith('tag:') or has_tags):
@@ -106,24 +134,30 @@
106 rev = RevisionSpec.from_string(revision)134 rev = RevisionSpec.from_string(revision)
107135
108 log(msg % {'status': status, 'type': typ, 'to': local, 'from': frm})136 log(msg % {'status': status, 'type': typ, 'to': local, 'from': frm})
109 137
110 cmd[status](bzrdir, local, rev and [rev] or None)138 cmd[status](bzrdir, local, rev and [rev] or None)
111139
140 for folder_links in bzr_folders_links:
141 if not os.path.exists(os.path.join(dest_dir, folder_links)):
142 os.makedirs(os.path.join(dest_dir, folder_links))
143
112 # Doing symlinks144 # Doing symlinks
113 log('(Re)Computing Symbolic links...')145 log('(Re)Computing Symbolic links...')
114 for src2,dest2 in bzr_links.items():146 for src2, dest2 in bzr_links.items():
115 src2 = os.path.join(dest_dir, src2)147 src2 = os.path.join(dest_dir, src2)
116 dest2 = os.path.join(dest_dir, dest2)148 dest2 = os.path.join(dest_dir, dest2)
117 for src in glob.glob(src2):149 for src in glob(src2):
118 dest = os.path.join(dest2, os.path.basename(src))150 dest = os.path.join(dest2, os.path.basename(src))
119 if not os.path.isdir(dest):151 if not os.path.isdir(dest):
120 os.symlink(os.path.realpath(src), dest)152 os.symlink(os.path.realpath(src), dest)
121153
122 log('='*79)154 log('=' * 79)
123 log('Sources of OpenERP have been installed. If you develop new features,')155 log('Sources of OpenERP have been installed. ' +
124 log('you can get more information on how to contribute to the project here:')156 'If you develop new features,')
125 log('\thttp://test.openobject.com')157 log('you can get more information on how to ' +
126 log('='*79)158 'contribute to the project here:')
159 log('\thttps://launchpad.net/openobject')
160 log('=' * 79)
127161
128#162#
129# Testing bzr send163# Testing bzr send
@@ -131,18 +165,29 @@
131165
132if __name__ == '__main__':166if __name__ == '__main__':
133 import optparse167 import optparse
134 description = """Tool that allows you to get the last sources of openerp on launchpad.168 description = """Tool that allows you to get the last sources of openerp on
135It downloads all branches, and create symlinks for addons in the server. By169launchpad. It downloads all branches, and create symlinks for addons in the
136default, it loads the latest stable version.170server. By default, it loads the latest stable version.
137"""171"""
138 parser = optparse.OptionParser(description=description, 172 parser = optparse.OptionParser(description=description,
139 usage="%prog [options] [directory]")173 usage="%prog [options] [directory]")
140 parser.add_option('--checkout', dest='lplogin', help="Specify the launchpad login to make a checkout instead of a branch")174 parser.add_option('--checkout', dest='lplogin',
141 parser.add_option('--export', dest='export', help='Make an export of the sources, instead of branches', action='store_true', default=False)175 help="Specify the launchpad login to make a checkout " +
142 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)")176 "instead of a branch")
143 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)")177 parser.add_option('--export', dest='export',
144 parser.add_option('-q', '--quiet', dest='quiet', help='Suppress the output', action='store_true', default=False)178 help='Make an export of the sources, instead of ' +
179 'branches', action='store_true', default=False)
180 parser.add_option('-v', dest="version", default=_DEFAULT_VERSION,
181 type="choice", choices=_VERSIONS,
182 help="Specify the version to take " +
183 "(trunk, 4.2, 5.0, 6.0)")
184 parser.add_option('-r', dest="revision", default=None,
185 help="Specify the revision to take. (useful to take a " +
186 "specific TAG or to specify a DATE)")
187 parser.add_option('-q', '--quiet', dest='quiet',
188 help='Suppress the output', action='store_true',
189 default=False)
145 opt, args = parser.parse_args()190 opt, args = parser.parse_args()
146 dest_dir = args and args[0] or '.'191 dest_dir = args and args[0] or '.'
147 update_openerp(dest_dir, opt.version, opt.lplogin, opt.export, opt.revision, not opt.quiet)192 update_openerp(dest_dir, opt.version, opt.lplogin, opt.export,
148193 opt.revision, not opt.quiet)
149194
=== added file 'test_bzr_set.py'
--- test_bzr_set.py 1970-01-01 00:00:00 +0000
+++ test_bzr_set.py 2011-10-07 13:03:45 +0000
@@ -0,0 +1,46 @@
1#!/usr/bin/env python
2import unittest
3
4from os import getcwd
5from os.path import exists
6from shutil import rmtree
7from time import time
8
9from bzr_set import _VERSIONS, update_openerp
10
11
12class TestBzrSet(unittest.TestCase):
13
14 def setUp(self):
15 self.path = getcwd() + "/TestBzrSet/"
16
17 def test_install_and_update(self):
18 """ Test install and update all version with verbose
19 """
20
21 if exists(self.path):
22 rmtree(self.path)
23
24 # test install
25 for version in _VERSIONS:
26 print "Test Install Version %s " % version
27 dest_dir = self.path + version
28 time_start = time()
29 update_openerp(dest_dir, version, verbose=True)
30 time_duration = time() - time_start
31 print "Duration : %s minutes %2.2f secondes " % \
32 (int(float(time_duration) / 60), (float(time_duration) % 60))
33 # test update
34 for version in _VERSIONS:
35 print "Test Update Version %s " % version
36 dest_dir = self.path + version
37 time_start = time()
38 update_openerp(dest_dir, version, verbose=True)
39 time_duration = time() - time_start
40 print "Duration : %2.2f secondes " % (float(time_duration) % 60)
41
42 rmtree(self.path)
43
44
45if __name__ == '__main__':
46 unittest.main()