Better fix for mx.DateTime.strptime function

This function exists depending of the platform so we make duck typing
This commit is contained in:
Cédric Krier
2008-06-14 12:55:59 +02:00
parent d588494a75
commit 06d4c2e09c
2 changed files with 10 additions and 3 deletions
+4 -3
View File
@@ -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()
+6
View File
@@ -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()