[MERGE] server: remove unused imports (Thanks to Florent Xicluna)
bzr revid: stw@openerp.com-20120910144609-ad3gupkf3oseb8yy
This commit is contained in:
commit
f55028de4d
|
@ -30,7 +30,6 @@ GNU Public Licence.
|
||||||
(c) 2003-TODAY, Fabien Pinckaers - OpenERP SA
|
(c) 2003-TODAY, Fabien Pinckaers - OpenERP SA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import imp
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
@ -203,7 +202,7 @@ def quit_on_signals():
|
||||||
try:
|
try:
|
||||||
while quit_signals_received == 0:
|
while quit_signals_received == 0:
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
except KeyboardInterrupt, e:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if config['pidfile']:
|
if config['pidfile']:
|
||||||
|
|
|
@ -86,12 +86,12 @@ class Service(object):
|
||||||
cls._services.pop(name)
|
cls._services.pop(name)
|
||||||
|
|
||||||
def LocalService(name):
|
def LocalService(name):
|
||||||
# Special case for addons support, will be removed in a few days when addons
|
# Special case for addons support, will be removed in a few days when addons
|
||||||
# are updated to directly use openerp.osv.osv.service.
|
# are updated to directly use openerp.osv.osv.service.
|
||||||
if name == 'object_proxy':
|
if name == 'object_proxy':
|
||||||
return openerp.osv.osv.service
|
return openerp.osv.osv.service
|
||||||
|
|
||||||
return Service._services[name]
|
return Service._services[name]
|
||||||
|
|
||||||
class ExportService(object):
|
class ExportService(object):
|
||||||
""" Proxy for exported services.
|
""" Proxy for exported services.
|
||||||
|
@ -238,9 +238,9 @@ def init_logger():
|
||||||
# server intended to test it.
|
# server intended to test it.
|
||||||
def init_alternative_logger():
|
def init_alternative_logger():
|
||||||
class H(logging.Handler):
|
class H(logging.Handler):
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
if record.levelno > 20:
|
if record.levelno > 20:
|
||||||
print record.levelno, record.pathname, record.msg
|
print record.levelno, record.pathname, record.msg
|
||||||
handler = H()
|
handler = H()
|
||||||
# Add the handler to the 'openerp' logger.
|
# Add the handler to the 'openerp' logger.
|
||||||
logger = logging.getLogger('openerp')
|
logger = logging.getLogger('openerp')
|
||||||
|
|
|
@ -892,8 +892,8 @@ class BaseModel(object):
|
||||||
for c in cls.__dict__.get(s, []):
|
for c in cls.__dict__.get(s, []):
|
||||||
exist = False
|
exist = False
|
||||||
for c2 in range(len(new)):
|
for c2 in range(len(new)):
|
||||||
#For _constraints, we should check field and methods as well
|
#For _constraints, we should check field and methods as well
|
||||||
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
|
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
|
||||||
or getattr(new[c2][0],'__name__', True) == \
|
or getattr(new[c2][0],'__name__', True) == \
|
||||||
getattr(c[0],'__name__', False)):
|
getattr(c[0],'__name__', False)):
|
||||||
# If new class defines a constraint with
|
# If new class defines a constraint with
|
||||||
|
@ -1308,7 +1308,7 @@ class BaseModel(object):
|
||||||
if not line[i]:
|
if not line[i]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if field[:len(prefix)] <> prefix:
|
if field[:len(prefix)] != prefix:
|
||||||
if line[i] and skip:
|
if line[i] and skip:
|
||||||
return False
|
return False
|
||||||
continue
|
continue
|
||||||
|
@ -2709,7 +2709,7 @@ class BaseModel(object):
|
||||||
# if val is a many2one, just write the ID
|
# if val is a many2one, just write the ID
|
||||||
if type(val) == tuple:
|
if type(val) == tuple:
|
||||||
val = val[0]
|
val = val[0]
|
||||||
if (val<>False) or (type(val)<>bool):
|
if val is not False:
|
||||||
cr.execute(update_query, (ss[1](val), key))
|
cr.execute(update_query, (ss[1](val), key))
|
||||||
|
|
||||||
def _check_selection_field_value(self, cr, uid, field, value, context=None):
|
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)):
|
elif val in dict(self._columns[field].selection(self, cr, uid, context=context)):
|
||||||
return
|
return
|
||||||
raise except_orm(_('ValidateError'),
|
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):
|
def _check_removed_columns(self, cr, log=False):
|
||||||
# iterate on the database columns to drop the NOT NULL constraints
|
# iterate on the database columns to drop the NOT NULL constraints
|
||||||
|
|
|
@ -44,10 +44,8 @@ import posixpath
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
|
|
||||||
|
|
||||||
from websrv_lib import *
|
from websrv_lib import *
|
||||||
import openerp.netsvc as netsvc
|
|
||||||
import openerp.tools as tools
|
import openerp.tools as tools
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -126,12 +126,12 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
|
||||||
ct.start()
|
ct.start()
|
||||||
lt = len(self.threads)
|
lt = len(self.threads)
|
||||||
if (lt > 10) and (lt % 10 == 0):
|
if (lt > 10) and (lt % 10 == 0):
|
||||||
# Not many threads should be serving at the same time, so log
|
# Not many threads should be serving at the same time, so log
|
||||||
# their abuse.
|
# their abuse.
|
||||||
_logger.debug("Netrpc: %d threads", len(self.threads))
|
_logger.debug("Netrpc: %d threads", len(self.threads))
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
except Exception, e:
|
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()
|
self.socket.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,9 @@ class db(netsvc.ExportService):
|
||||||
|
|
||||||
if not data or res:
|
if not data or res:
|
||||||
_logger.error(
|
_logger.error(
|
||||||
'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '\
|
'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 '\
|
'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))
|
'server configuration file.\n %s', db_name, data)
|
||||||
raise Exception, "Couldn't dump database"
|
raise Exception, "Couldn't dump database"
|
||||||
_logger.info('DUMP DB successful: %s', db_name)
|
_logger.info('DUMP DB successful: %s', db_name)
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ class db(netsvc.ExportService):
|
||||||
self._set_pg_psw_env_var()
|
self._set_pg_psw_env_var()
|
||||||
|
|
||||||
if self.exp_db_exist(db_name):
|
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"
|
raise Exception, "Database already exists"
|
||||||
|
|
||||||
self._create_empty_database(db_name)
|
self._create_empty_database(db_name)
|
||||||
|
@ -282,7 +282,7 @@ class db(netsvc.ExportService):
|
||||||
res = stdout.close()
|
res = stdout.close()
|
||||||
if res:
|
if res:
|
||||||
raise Exception, "Couldn't restore database"
|
raise Exception, "Couldn't restore database"
|
||||||
_logger.info('RESTORE DB: %s' % (db_name))
|
_logger.info('RESTORE DB: %s', db_name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
finally:
|
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'))
|
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):
|
if zips and not os.path.isdir(backup_directory):
|
||||||
_logger.info('create a new backup directory to \
|
_logger.info('create a new backup directory to store the old modules: %s', backup_directory)
|
||||||
store the old modules: %s', backup_directory)
|
|
||||||
os.makedirs(backup_directory)
|
os.makedirs(backup_directory)
|
||||||
|
|
||||||
for module in zips:
|
for module in zips:
|
||||||
|
@ -526,11 +525,11 @@ GNU Public Licence.
|
||||||
'OS Name : %s\n' \
|
'OS Name : %s\n' \
|
||||||
%(platform.platform(), platform.os.name)
|
%(platform.platform(), platform.os.name)
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
lsbinfo = os.popen('lsb_release -a').read()
|
lsbinfo = os.popen('lsb_release -a').read()
|
||||||
environment += '%s'%(lsbinfo)
|
environment += '%s'%(lsbinfo)
|
||||||
else:
|
else:
|
||||||
environment += 'Your System is not lsb compliant\n'
|
environment += 'Your System is not lsb compliant\n'
|
||||||
environment += 'Operating System Release : %s\n' \
|
environment += 'Operating System Release : %s\n' \
|
||||||
'Operating System Version : %s\n' \
|
'Operating System Version : %s\n' \
|
||||||
'Operating System Architecture : %s\n' \
|
'Operating System Architecture : %s\n' \
|
||||||
|
@ -695,7 +694,7 @@ class report_spool(netsvc.ExportService):
|
||||||
self._reports[id]['state'] = True
|
self._reports[id]['state'] = True
|
||||||
except Exception, exception:
|
except Exception, exception:
|
||||||
|
|
||||||
_logger.exception('Exception: %s\n', str(exception))
|
_logger.exception('Exception: %s\n', exception)
|
||||||
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
||||||
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
||||||
else:
|
else:
|
||||||
|
@ -732,7 +731,7 @@ class report_spool(netsvc.ExportService):
|
||||||
self._reports[id]['format'] = format
|
self._reports[id]['format'] = format
|
||||||
self._reports[id]['state'] = True
|
self._reports[id]['state'] = True
|
||||||
except Exception, exception:
|
except Exception, exception:
|
||||||
_logger.exception('Exception: %s\n', str(exception))
|
_logger.exception('Exception: %s\n', exception)
|
||||||
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
||||||
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -27,7 +27,6 @@ class m(openerp.osv.osv.Model):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def consume_cpu_time(self, cr, uid, seconds, context=None):
|
def consume_cpu_time(self, cr, uid, seconds, context=None):
|
||||||
import os
|
|
||||||
t0 = time.clock()
|
t0 = time.clock()
|
||||||
t1 = time.clock()
|
t1 = time.clock()
|
||||||
while t1 - t0 < seconds:
|
while t1 - t0 < seconds:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import os
|
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
import socket
|
import socket
|
||||||
import cPickle
|
import cPickle
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import marshal
|
|
||||||
|
|
||||||
import netsvc
|
import netsvc
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import openerp.pooler as pooler
|
||||||
|
|
||||||
from openerp.osv.osv import except_osv
|
from openerp.osv.osv import except_osv
|
||||||
from openerp.osv.orm import except_orm
|
from openerp.osv.orm import except_orm
|
||||||
import sys
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -168,10 +167,7 @@ class interface(netsvc.Service):
|
||||||
or isinstance(e, except_orm):
|
or isinstance(e, except_orm):
|
||||||
netsvc.abort_response(2, e.name, 'warning', e.value)
|
netsvc.abort_response(2, e.name, 'warning', e.value)
|
||||||
else:
|
else:
|
||||||
import traceback
|
_logger.exception('Exception in call:')
|
||||||
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)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue