From 06d4c2e09cefffc123227ec3011593b6ffa7d3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 14 Jun 2008 12:55:59 +0200 Subject: [PATCH] Better fix for mx.DateTime.strptime function This function exists depending of the platform so we make duck typing --- trytond/ir/cron.py | 7 ++++--- trytond/trytond.py | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/trytond/ir/cron.py b/trytond/ir/cron.py index 960ccb62d3..55d3dad5a3 100644 --- a/trytond/ir/cron.py +++ b/trytond/ir/cron.py @@ -94,8 +94,8 @@ class Cron(OSV, Agent): 'AND nextcall <= now() ' \ 'ORDER BY priority') for job in cursor.dictfetchall(): - nextcall = DateTime.mktime(time.strptime(str(job['nextcall']), - '%Y-%m-%d %H:%M:%S')) + nextcall = DateTime.strptime(str(job['nextcall']), + '%Y-%m-%d %H:%M:%S') numbercall = job['numbercall'] done = False while nextcall < now and numbercall: @@ -114,7 +114,8 @@ class Cron(OSV, Agent): cursor.execute("UPDATE ir_cron SET nextcall = %s, " \ "numbercall = %s" + addsql + " " \ "WHERE id = %s", - (nextcall, numbercall, job['id'])) + (nextcall.strftime('%Y-%m-%d %H:%M:%S'), + numbercall, job['id'])) cursor.commit() finally: cursor.close() diff --git a/trytond/trytond.py b/trytond/trytond.py index d72ba87103..3f4243078f 100644 --- a/trytond/trytond.py +++ b/trytond/trytond.py @@ -41,6 +41,7 @@ import web_service import wkf_service from module import register_classes import osv, security, tools, version +import mx.DateTime #Fix for pyxml for ubuntu sys.path.append('/usr/lib/python%s/site-packages/oldxml' % sys.version[:3]) @@ -51,12 +52,17 @@ class TrytonServer(object): netsvc.init_logger() self.logger = netsvc.Logger() + if not hasattr(mx.DateTime, 'strptime'): + mx.DateTime.strptime = lambda x, y: mx.DateTime.mktime( + time.strptime(x, y)) + self.logger.notify_channel("objects", netsvc.LOG_INFO, 'initialising distributed objects services') self.dispatcher = netsvc.Dispatcher() self.dispatcher.monitor(signal.SIGINT) + web_service.DB() web_service.Common() web_service.Object()