From 5c3609a5705dd4768df08219a56c816ca522d718 Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 9 Aug 2007 08:18:06 +0000 Subject: [PATCH] fix raise string deprecated in python 2.5 bzr revid: ced-ba57e04979dcd47a40b22b2b586489996b06a3d9 --- bin/addons/base/module/module.py | 4 ++-- bin/addons/module_graph.py | 2 +- bin/osv/fields.py | 4 ++-- bin/osv/orm.py | 2 +- bin/report/interface.py | 2 +- bin/service/web_services.py | 25 ++++++++++++------------- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index 98fb4bd07a5..08015196f77 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -262,7 +262,7 @@ class module(osv.osv): def state_change(self, cr, uid, ids, newstate, context={}, level=50): if level<1: - raise 'Recursion error in modules dependencies !' + raise Exception, 'Recursion error in modules dependencies !' demo = True for module in self.browse(cr, uid, ids): mdemo = True @@ -280,7 +280,7 @@ class module(osv.osv): def state_upgrade(self, cr, uid, ids, newstate, context=None, level=50): dep_obj = self.pool.get('ir.module.module.dependency') if level<1: - raise 'Recursion error in modules dependencies !' + raise Exception, 'Recursion error in modules dependencies !' for module in self.browse(cr, uid, ids): dep_ids = dep_obj.search(cr, uid, [('name', '=', module.name)]) if dep_ids: diff --git a/bin/addons/module_graph.py b/bin/addons/module_graph.py index a4e2efde9aa..865802526ba 100644 --- a/bin/addons/module_graph.py +++ b/bin/addons/module_graph.py @@ -4,7 +4,7 @@ import os import sys if not len(sys.argv)>1: - raise 'Usage: gen_graph.sh module1 module2 module3' + raise Exception, 'Usage: gen_graph.sh module1 module2 module3' modules = sys.argv[1:] done = [] diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 4d8bc2e35de..9f765882418 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -94,7 +94,7 @@ class _column(object): cr.execute('update '+obj._table+' set '+name+'='+self._symbol_set[0]+' where id=%d', (self._symbol_set[1](value),id) ) def get(self, cr, obj, ids, name, context=None, values=None): - raise 'undefined get method !' + raise Exception, 'undefined get method !' def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None): ids = obj.search(cr, uid, args+self._domain+[(name,'ilike',value)], offset, limit) @@ -219,7 +219,7 @@ class selection(_column): # la raison est que selection n'est pas en classic_write = false # a noter qu'on pourrait fournir un _symbol_set specifique, et ca suffirait if value in self.selection: - raise 'BAD VALUE' + raise Exception, 'BAD VALUE' _column.set(self, cr, obj, id, name, value, user=None, context=context) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 6e6c35f0955..8634e61c26c 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -603,7 +603,7 @@ class orm(object): # for i in range(len(fields)): if i>=len(line): - raise 'Please check that all your lines have %d cols.' % (len(fields),) + raise Exception, 'Please check that all your lines have %d cols.' % (len(fields),) field = fields[i] if field == ["id"]: data_id= line[i] diff --git a/bin/report/interface.py b/bin/report/interface.py index 8974a8a1839..74fa8fcbc0a 100644 --- a/bin/report/interface.py +++ b/bin/report/interface.py @@ -57,7 +57,7 @@ class report_int(netsvc.Service): assert not netsvc.service_exist(name), 'The report "%s" already exist!'%name super(report_int, self).__init__(name, audience) if name[0:7]<>'report.': - raise 'ConceptionError, bad report name, should start with "report."' + raise Exception, 'ConceptionError, bad report name, should start with "report."' self.name = name self.id = 0 self.name2 = '.'.join(name.split('.')[1:]) diff --git a/bin/service/web_services.py b/bin/service/web_services.py index 8db9abbda78..3fc8e5c6a70 100644 --- a/bin/service/web_services.py +++ b/bin/service/web_services.py @@ -117,8 +117,8 @@ class db(netsvc.Service): create_thread.start() self.actions[id]['thread'] = create_thread return id - raise "Couldn't create database" - + raise Exception, "Couldn't create database" + def get_progress(self, password, id): security.check_super(password) if self.actions[id]['thread'].isAlive(): @@ -131,10 +131,9 @@ class db(netsvc.Service): del self.actions[id] return (1.0, users) else: - print self.actions[id]['traceback'] e = self.actions[id]['exception'] del self.actions[id] - raise e + raise Exception, e def drop(self, password, db_name): security.check_super(password) @@ -146,7 +145,7 @@ class db(netsvc.Service): logger = netsvc.Logger() if res: logger.notifyChannel("web-service", netsvc.LOG_ERROR, 'DROP DB: %s failed' % (db_name,)) - raise "Couldn't drop database" + raise Exception, "Couldn't drop database" else: logger.notifyChannel("web-services", netsvc.LOG_INFO, 'DROP DB: %s' % (db_name)) return True @@ -164,7 +163,7 @@ class db(netsvc.Service): logger = netsvc.Logger() if res: logger.notifyChannel("web-service", netsvc.LOG_ERROR, 'DUMP DB: %s failed\n%s' % (db_name, data)) - raise "Couldn't dump database" + raise Exception, "Couldn't dump database" logger.notifyChannel("web-services", netsvc.LOG_INFO, 'DUMP DB: %s' % (db_name)) return base64.encodestring(data) @@ -172,7 +171,7 @@ class db(netsvc.Service): security.check_super(password) res = True if self.db_exist(db_name): - raise "Database already exists" + raise Exception, "Database already exists" else: if tools.config['db_user']: args = ('createdb', '--quiet', '--encoding=unicode', '--username='+tools.config['db_user'], db_name) @@ -196,11 +195,11 @@ class db(netsvc.Service): stdin.close() res = stdout.close() if res: - raise "Couldn't restore database" + raise Exception, "Couldn't restore database" logger = netsvc.Logger() logger.notifyChannel("web-services", netsvc.LOG_INFO, 'RESTORE DB: %s' % (db_name)) return True - raise "Couldn't create database" + raise Exception, "Couldn't create database" def db_exist(self, db_name): try: @@ -385,9 +384,9 @@ class wizard(netsvc.Service): if self.wiz_uid[wiz_id] == uid: return self._execute(db, uid, wiz_id, datas, action, context) else: - raise 'AccessDenied' + raise Exception, 'AccessDenied' else: - raise 'WizardNotFound' + raise Exception, 'WizardNotFound' wizard() # @@ -460,9 +459,9 @@ class report_spool(netsvc.Service): if self._reports[report_id]['uid'] == uid: return self._check_report(report_id) else: - raise 'AccessDenied' + raise Exception, 'AccessDenied' else: - raise 'ReportNotFound' + raise Exception, 'ReportNotFound' report_spool()