[MERGE] server: remove unused imports (Thanks to Florent Xicluna)

bzr revid: stw@openerp.com-20120910144609-ad3gupkf3oseb8yy
This commit is contained in:
Stephane Wirtel 2012-09-10 16:46:09 +02:00
commit f55028de4d
10 changed files with 32 additions and 43 deletions

View File

@ -30,7 +30,6 @@ GNU Public Licence.
(c) 2003-TODAY, Fabien Pinckaers - OpenERP SA
"""
import imp
import logging
import os
import signal
@ -203,7 +202,7 @@ def quit_on_signals():
try:
while quit_signals_received == 0:
time.sleep(60)
except KeyboardInterrupt, e:
except KeyboardInterrupt:
pass
if config['pidfile']:

View File

@ -86,12 +86,12 @@ class Service(object):
cls._services.pop(name)
def LocalService(name):
# Special case for addons support, will be removed in a few days when addons
# are updated to directly use openerp.osv.osv.service.
if name == 'object_proxy':
return openerp.osv.osv.service
# Special case for addons support, will be removed in a few days when addons
# are updated to directly use openerp.osv.osv.service.
if name == 'object_proxy':
return openerp.osv.osv.service
return Service._services[name]
return Service._services[name]
class ExportService(object):
""" Proxy for exported services.
@ -238,9 +238,9 @@ def init_logger():
# server intended to test it.
def init_alternative_logger():
class H(logging.Handler):
def emit(self, record):
if record.levelno > 20:
print record.levelno, record.pathname, record.msg
def emit(self, record):
if record.levelno > 20:
print record.levelno, record.pathname, record.msg
handler = H()
# Add the handler to the 'openerp' logger.
logger = logging.getLogger('openerp')

View File

@ -892,8 +892,8 @@ class BaseModel(object):
for c in cls.__dict__.get(s, []):
exist = False
for c2 in range(len(new)):
#For _constraints, we should check field and methods as well
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
#For _constraints, we should check field and methods as well
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
or getattr(new[c2][0],'__name__', True) == \
getattr(c[0],'__name__', False)):
# If new class defines a constraint with
@ -1308,7 +1308,7 @@ class BaseModel(object):
if not line[i]:
continue
if field[:len(prefix)] <> prefix:
if field[:len(prefix)] != prefix:
if line[i] and skip:
return False
continue
@ -2709,7 +2709,7 @@ class BaseModel(object):
# if val is a many2one, just write the ID
if type(val) == tuple:
val = val[0]
if (val<>False) or (type(val)<>bool):
if val is not False:
cr.execute(update_query, (ss[1](val), key))
def _check_selection_field_value(self, cr, uid, field, value, context=None):
@ -2733,7 +2733,7 @@ class BaseModel(object):
elif val in dict(self._columns[field].selection(self, cr, uid, context=context)):
return
raise except_orm(_('ValidateError'),
_('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field))
_('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field))
def _check_removed_columns(self, cr, log=False):
# iterate on the database columns to drop the NOT NULL constraints

View File

@ -44,10 +44,8 @@ import posixpath
import urllib
import os
import logging
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
from websrv_lib import *
import openerp.netsvc as netsvc
import openerp.tools as tools
try:

View File

@ -126,12 +126,12 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
ct.start()
lt = len(self.threads)
if (lt > 10) and (lt % 10 == 0):
# Not many threads should be serving at the same time, so log
# their abuse.
_logger.debug("Netrpc: %d threads", len(self.threads))
# Not many threads should be serving at the same time, so log
# their abuse.
_logger.debug("Netrpc: %d threads", len(self.threads))
self.socket.close()
except Exception, e:
_logger.warning("Netrpc: closing because of exception %s" % str(e))
_logger.warning("Netrpc: closing because of exception %s", e)
self.socket.close()
return False

View File

@ -238,9 +238,9 @@ class db(netsvc.ExportService):
if not data or res:
_logger.error(
'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '\
'It should be provided as a -w <PASSWD> command-line option, or as `db_password` in the '\
'server configuration file.\n %s' % (db_name, data))
'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '
'It should be provided as a -w <PASSWD> command-line option, or as `db_password` in the '
'server configuration file.\n %s', db_name, data)
raise Exception, "Couldn't dump database"
_logger.info('DUMP DB successful: %s', db_name)
@ -253,7 +253,7 @@ class db(netsvc.ExportService):
self._set_pg_psw_env_var()
if self.exp_db_exist(db_name):
_logger.warning('RESTORE DB: %s already exists' % (db_name,))
_logger.warning('RESTORE DB: %s already exists', db_name)
raise Exception, "Database already exists"
self._create_empty_database(db_name)
@ -282,7 +282,7 @@ class db(netsvc.ExportService):
res = stdout.close()
if res:
raise Exception, "Couldn't restore database"
_logger.info('RESTORE DB: %s' % (db_name))
_logger.info('RESTORE DB: %s', db_name)
return True
finally:
@ -465,8 +465,7 @@ GNU Public Licence.
backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
if zips and not os.path.isdir(backup_directory):
_logger.info('create a new backup directory to \
store the old modules: %s', backup_directory)
_logger.info('create a new backup directory to store the old modules: %s', backup_directory)
os.makedirs(backup_directory)
for module in zips:
@ -526,11 +525,11 @@ GNU Public Licence.
'OS Name : %s\n' \
%(platform.platform(), platform.os.name)
if os.name == 'posix':
if platform.system() == 'Linux':
lsbinfo = os.popen('lsb_release -a').read()
environment += '%s'%(lsbinfo)
else:
environment += 'Your System is not lsb compliant\n'
if platform.system() == 'Linux':
lsbinfo = os.popen('lsb_release -a').read()
environment += '%s'%(lsbinfo)
else:
environment += 'Your System is not lsb compliant\n'
environment += 'Operating System Release : %s\n' \
'Operating System Version : %s\n' \
'Operating System Architecture : %s\n' \
@ -695,7 +694,7 @@ class report_spool(netsvc.ExportService):
self._reports[id]['state'] = True
except Exception, exception:
_logger.exception('Exception: %s\n', str(exception))
_logger.exception('Exception: %s\n', exception)
if hasattr(exception, 'name') and hasattr(exception, 'value'):
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
else:
@ -732,7 +731,7 @@ class report_spool(netsvc.ExportService):
self._reports[id]['format'] = format
self._reports[id]['state'] = True
except Exception, exception:
_logger.exception('Exception: %s\n', str(exception))
_logger.exception('Exception: %s\n', exception)
if hasattr(exception, 'name') and hasattr(exception, 'value'):
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
else:

View File

@ -27,7 +27,6 @@ class m(openerp.osv.osv.Model):
return True
def consume_cpu_time(self, cr, uid, seconds, context=None):
import os
t0 = time.clock()
t1 = time.clock()
while t1 - t0 < seconds:

View File

@ -1,4 +1,3 @@
import os
import unittest2
import openerp

View File

@ -22,7 +22,6 @@
import socket
import cPickle
import cStringIO
import marshal
import netsvc

View File

@ -31,7 +31,6 @@ import openerp.pooler as pooler
from openerp.osv.osv import except_osv
from openerp.osv.orm import except_orm
import sys
_logger = logging.getLogger(__name__)
@ -168,10 +167,7 @@ class interface(netsvc.Service):
or isinstance(e, except_orm):
netsvc.abort_response(2, e.name, 'warning', e.value)
else:
import traceback
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
sys.exc_type, sys.exc_value, sys.exc_traceback))
_logger.error('Exception in call: ' + tb_s)
_logger.exception('Exception in call:')
raise
return res