Opened 17 years ago
Closed 14 years ago
#2269 closed defect (fixed)
Notification error using 0.11-dev and xmlrpc trunk
Reported by: | Daniel Mayer | Owned by: | osimons |
---|---|---|---|
Priority: | high | Component: | XmlRpcPlugin |
Severity: | normal | Keywords: | |
Cc: | Thijs Triemstra | Trac Release: | 0.11 |
Description
Hi,
using Trac 0.11-dev (r6280) and the xmlrpc plugin (trunk) notifications cannot be send after changes to a ticket are comittet (using mylyn in my case). The traceback in the logfile is provided below and its coming down to a wrong format of the "now" time which is passed on to the TracNotifier.
Notifications when changing a ticket through the webinterface work perfectly.
2007-12-05 03:06:29,257 Trac[__init__] ERROR: Failure sending notification on change of ticket #26: unsupported operand type(s) for -: 'float' and 'datetime.datetime' Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/TracXMLRPC-1.0.0-py2.4.egg/tracrpc/ticket.py", line 109, in update tn.notify(t, newticket=False, modtime=now) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6280-py2.4.egg/trac/ticket/notification.py", line 81, in notify for change in TicketModule(self.env).grouped_changelog_entries( File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6280-py2.4.egg/trac/ticket/web_ui.py", line 1253, in grouped_changelog_entries changelog = ticket.get_changelog(when=when, db=db) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6280-py2.4.egg/trac/ticket/model.py", line 286, in get_changelog when_ts = when and to_timestamp(when) or 0 File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6280-py2.4.egg/trac/util/datefmt.py", line 55, in to_timestamp diff = dt - _epoc TypeError: unsupported operand type(s) for -: 'float' and 'datetime.datetime'
Attachments (0)
Change History (13)
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
Try this diff:
-
trunk/tracrpc/ticket.py
8 8 from trac.ticket.api import TicketSystem 9 9 from trac.ticket.notification import TicketNotifyEmail 10 10 11 importtime11 from datetime import datetime 12 12 import inspect 13 13 import xmlrpclib 14 14 from StringIO import StringIO … … 96 96 97 97 def update(self, req, id, comment, attributes = {}, notify=False): 98 98 """ Update a ticket, returning the new ticket in the same form as getTicket(). """ 99 now = time.time()99 now = datetime.now() 100 100 101 101 t = model.Ticket(self.env, id) 102 102 for k, v in attributes.iteritems():
comment:3 Changed 17 years ago by
Improved the situation but I get now:
2007-12-07 17:06:05,057 Trac[__init__] ERROR: Failure sending notification on change of ticket #40: can't subtract offset-naive and offset-aware datetimes Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/TracXMLRPC-1.0.0-py2.4.egg/tracrpc/ticket.py", line 109, in update tn.notify(t, newticket=False, modtime=now) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/notification.py", line 81, in notify for change in TicketModule(self.env).grouped_changelog_entries( File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/web_ui.py", line 1253, in grouped_changelog_entries changelog = ticket.get_changelog(when=when, db=db) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/model.py", line 286, in get_changelog when_ts = when and to_timestamp(when) or 0 File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/util/datefmt.py", line 55, in to_timestamp diff = dt - _epoc TypeError: can't subtract offset-naive and offset-aware datetimes
comment:5 Changed 17 years ago by
I changed the update funtction to
def update(self, req, id, comment, attributes = {}, notify=False): """ Update a ticket, returning the new ticket in the same form as getTicket(). """ now = datetime.utcnow()
does not change anything
2007-12-07 17:38:57,288 Trac[__init__] ERROR: Failure sending notification on change of ticket #40: can't subtract offset-naive and offset-aware datetimes Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/TracXMLRPC-1.0.0-py2.4.egg/tracrpc/ticket.py", line 109, in update tn.notify(t, newticket=False, modtime=now) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/notification.py", line 81, in notify for change in TicketModule(self.env).grouped_changelog_entries( File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/web_ui.py", line 1253, in grouped_changelog_entries changelog = ticket.get_changelog(when=when, db=db) File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/ticket/model.py", line 286, in get_changelog when_ts = when and to_timestamp(when) or 0 File "/usr/lib/python2.4/site-packages/Trac-0.11dev_r6285-py2.4.egg/trac/util/datefmt.py", line 55, in to_timestamp diff = dt - _epoc TypeError: can't subtract offset-naive and offset-aware datetimes
comment:6 Changed 17 years ago by
I assume the solution is to give the now() function the timezone it should assume.
e.g. datetime.now(utc) or datetime.now(localtz)
I am not sure which one is the correct one though. I will try it with the UTC and see if i will run in some time-deviations. Hope that helps.
comment:7 Changed 17 years ago by
so i think this fixes it completely. Here is the new diff to trunk:
--- trunk/tracrpc/ticket.py (revision 2626) +++ trunk/tracrpc/ticket.py (working copy) @@ -7,8 +7,10 @@ import trac.ticket.query as query from trac.ticket.api import TicketSystem from trac.ticket.notification import TicketNotifyEmail +from trac.util.datefmt import utc, to_timestamp -import time + +from datetime import datetime import inspect import xmlrpclib from StringIO import StringIO @@ -96,7 +98,7 @@ def update(self, req, id, comment, attributes = {}, notify=False): """ Update a ticket, returning the new ticket in the same form as getTicket(). """ - now = time.time() + now = datetime.now(utc) t = model.Ticket(self.env, id) for k, v in attributes.iteritems():
comment:9 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:10 follow-up: 13 Changed 15 years ago by
The changes made to resolve this issue are not in the latest trunk version. The import datetime from datetime is gone in some commit. So i reopen this issue now if it is ok.
comment:11 Changed 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:12 Changed 15 years ago by
Cc: | Thijs Triemstra added; anonymous removed |
---|---|
Owner: | changed from Alec Thomas to osimons |
Status: | reopened → new |
comment:13 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to ar@anrichter.net:
The changes made to resolve this issue are not in the latest trunk version. The import datetime from datetime is gone in some commit. So i reopen this issue now if it is ok.
No need. Currently a Trac util function is used instead, and now = to_datetime(None, utc)
does the same thing.
Re-closing ticket.
If somebody could point me in a direction on how the timestamp 'now' in ticket.py has to be converted (to which object or type) in order to be conform to the Trac-API and therefore be understood by /trac/util/datefmt.py I would be happy to implement this. This I a major issue for us using the Plugin because other developer rely on the notifications. I know that the 0.11 interface is not complete yet.