1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# $Id: config.py 996 2005-07-22 10:40:10Z nicoe $
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
38
# remove an existing version of modules if it exist
40
adp = tools.config['addons_path']
41
addons = os.listdir(adp)
44
shutil.rmtree(os.path.join(adp, name))
46
print "Unable to remove module %s !" % name
48
def install(name, url):
49
tar = tarfile.open(mode="r|gz", fileobj=urllib2.urlopen(url))
51
tar.extract(tarinfo, tools.config['addons_path'])
55
cr = pooler.db.cursor()
60
# print 'Check for correct rights (create and unlink on addons)...'
61
# todo: touch addons/test.txt
62
# todo: rm addons/test.txt
64
print 'Check for modules to remove...'
65
cr.execute('select id,name,url from ir_module_module where state=%s', ('to remove',))
66
for module_id,name,url in cr.fetchall():
67
print '\tremoving module %s' % name
69
cr.execute('update ir_module_module set state=%s where id=%d', ('uninstalled', module_id))
72
print 'Check for modules to upgrade...'
73
cr.execute('select id,name,url from ir_module_module where state=%s', ('to upgrade',))
74
for module_id,name,url in cr.fetchall():
75
print '\tupgrading module %s' % name
78
cr.execute('update ir_module_module set state=%s where id=%d', ('installed', module_id))
82
print 'Check for modules to install...'
83
cr.execute('select id,name,url from ir_module_module where state=%s', ('to install',))
84
for module_id,name,url in cr.fetchall():
85
print '\tinstalling module %s' % name
87
cr.execute('update ir_module_module set state=%s where id=%d', ('installed', module_id))
91
print 'Initializing all datas...'
95
return (toinit, toupdate)