Modify

Opened 16 years ago

Closed 13 years ago

Last modified 12 years ago

#4504 closed defect (fixed)

TypeError: a float is required

Reported by: mantas.kanaporis@… Owned by: daan
Priority: highest Component: ScrumBurndownPlugin
Severity: blocker Keywords:
Cc: Trac Release: 0.11

Description

After pressing "Start milestone", I get a "TypeError: a float is required" error message. For a full error trace see the attachment.

Attachments (1)

TracBurndown problem.png (76.4 KB) - added by mantas.kanaporis@… 16 years ago.
"TypeError: a float is required" error trace

Download all attachments as: .zip

Change History (24)

Changed 16 years ago by mantas.kanaporis@…

Attachment: TracBurndown problem.png added

"TypeError: a float is required" error trace

comment:1 Changed 16 years ago by daan

Owner: changed from Sam Bloomquist to daan

comment:2 Changed 16 years ago by daan

Hi,

Can you try to rename your milestone so no 'special characters' are in the milestone name? If that works, I know what to fix :-)

  • Daan

comment:3 Changed 16 years ago by mantas.kanaporis@…

Unfortunatelly, this didn't help. Tried to rename every milestone---same error.

comment:4 Changed 16 years ago by koen

same here :

Most recent call last:

    * File "/opt/csw/lib/python/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 423, in _dispatch_request
      Code fragment:
       418. try:
       419. if not env and env_error:
       420. raise HTTPInternalError(env_error)
       421. try:
       422. dispatcher = RequestDispatcher(env)
       423. dispatcher.dispatch(req)
       424. except RequestDone:
       425. pass
       426. resp = req._response or []
       427.  
       428. except HTTPException, e:
      Local variables:
      Name	Value
      after 	[u' except RequestDone:', u' pass', u' resp = ...
      before 	[u' try:', u' if not env and env_error:', u' raise ...
      dispatcher 	<trac.web.main.RequestDispatcher object at 0x8d6f84c>
      e 	TypeError('a float is required',)
      env 	<trac.env.Environment object at 0x8827d6c>
      env_error 	None
      exc_info 	(<type 'exceptions.TypeError'>, TypeError('a float is required',), ...
      filename 	'/opt/csw/lib/python/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py'
      frames 	[{'function': '_dispatch_request', 'lines_before': [u' try:', u' ...
      has_admin 	True
      line 	u' dispatcher.dispatch(req)'
      lineno 	422
      message 	u'TypeError: a float is required'
      req 	<Request "GET u'/burndown'">
      resp 	[]
      tb 	<traceback object at 0x92d9b6c>
      tb_hide 	None
      traceback 	'Traceback (most recent call last):\n File ...
    * File "/opt/csw/lib/python/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 197, in dispatch
      Code fragment:
       192. req.args.get('__FORM_TOKEN') != req.form_token:
       193. raise HTTPBadRequest('Missing or invalid form token. '
       194. 'Do you have cookies enabled?')
       195.  
       196. # Process the request and render the template
       197. resp = chosen_handler.process_request(req)
       198. if resp:
       199. if len(resp) == 2: # Clearsilver
       200. chrome.populate_hdf(req)
       201. template, content_type = \
       202. self._post_process_request(req, *resp)
      Local variables:
      Name	Value
      chosen_handler 	<burndown.burndown.BurndownComponent object at 0x8d6f52c>
      chrome 	<trac.web.chrome.Chrome object at 0x8cc626c>
      err 	(<type 'exceptions.TypeError'>, TypeError('a float is required',), ...
      handler 	<burndown.burndown.BurndownComponent object at 0x8d6f52c>
      req 	<Request "GET u'/burndown'">
      self 	<trac.web.main.RequestDispatcher object at 0x8d6f84c>
    * File "build/bdist.linux-i686/egg/burndown/burndown.py", line 166, in process_request
      Local variables:
      Name	Value
      components 	[{'owner': u'koen', 'name': u'hibernate domain model', 'description': ...
      data 	{'milestones': [{'started': None, 'completed': 0, 'description': ...
      db 	<trac.db.pool.PooledConnection object at 0x90c082c>
      empty_db_for_testing 	'false'
      milestones 	[{'started': None, 'completed': 0, 'description': u'refactor address ...
      req 	<Request "GET u'/burndown'">
      selected_component 	u'All Components'
      selected_milestone 	{'started': None, 'completed': 0, 'description': u'\r\n * refactor ...
      self 	<burndown.burndown.BurndownComponent object at 0x8d6f52c>
    * File "build/bdist.linux-i686/egg/burndown/burndown.py", line 233, in start_milestone
      Local variables:
      Name	Value
      db 	<trac.db.pool.PooledConnection object at 0x90c082c>
      milestone 	u'Locations functionality and domain model changes'
      self 	<burndown.burndown.BurndownComponent object at 0x8d6f52c>
    * File "build/bdist.linux-i686/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone
      Local variables:
      Name	Value
      cursor 	<trac.db.util.IterableCursor object at 0x90b6a64>
      db 	<trac.db.pool.PooledConnection object at 0x90c082c>
      milestone 	u'Locations functionality and domain model changes'
      row 	(None,)

comment:5 Changed 16 years ago by jan0sch@…

I get the same error when I try to start a milestone. I did not get this error before switching to german date format (DD.MM.YYYY via PythonOption TracLocale de_DE.UTF8) but switching back did not resolve the problem (same error message).

Oops…
Trac detected an internal error: 

If you think this really should work and you can reproduce it, you should consider reporting this problem to the Trac team.

Go to http://trac.edgewall.org/ and create a new ticket where you describe the problem, how to reproduce it. Don't forget to include the Python traceback found below.

TracGuide — The Trac User and Administration Guide 
Python Traceback
Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 406, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/burndown/burndown.py", line 166, in process_request
    self.start_milestone(db, selected_milestone['name'])
  File "build/bdist.linux-i686/egg/burndown/burndown.py", line 233, in start_milestone
    startdate = dbhelper.get_startdate_for_milestone(db, milestone)
  File "build/bdist.linux-i686/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone
    return datetime.fromtimestamp(row[0])
TypeError: a float is required

comment:6 Changed 16 years ago by cj

I get the same problem, but only with newly created milestones. It works fine for milestones created before i installed the plugin.

comment:7 Changed 16 years ago by mantas.kanaporis@…

ok. seems that after going to "Adminstration" > "Scrum Burndown Plugin Settings" and manually setting the start of the milestone, the burndown starts collecting data. And in a few days time you can see the curve appearing.

comment:8 Changed 16 years ago by shu.shen@…

The same problem happens to my 0.10 trac installation. I found in the database the newly create milestone has null as "started" field. Problem is solved by manually setting this field as "0" by using sqlite.

I believe this is a bug that: 1) forgot to properly set the "started" when creating a new milestone, and 2) wrong handling code in get_startdate_for_milestone() of dhhelper.py

comment:9 Changed 16 years ago by anonymous

An easy fix is as below:

  • dbhelper.py

     
    9292    cursor.execute("SELECT started FROM milestone WHERE name = %s", [milestone])
    9393    row = cursor.fetchone()
    9494
    95     if(row and row[0]!=0):
     95    if(row and row[0] and row[0]!=0):
    9696        return datetime.fromtimestamp(row[0])
    9797    else:
    9898        return None

comment:11 in reply to:  10 ; Changed 16 years ago by anonymous

Replying to shu.shen@gmail.com:

Repost patch with format

Index: dbhelper.py
===================================================================
--- dbhelper.py (revision 5529)
+++ dbhelper.py (working copy)
@@ -92,7 +92,7 @@
     cursor.execute("SELECT started FROM milestone WHERE name = %s", [milestone])
     row = cursor.fetchone()

-    if(row and row[0]!=0):
+    if(row and row[0] and row[0]!=0):
         return datetime.fromtimestamp(row[0])
     else:
         return None

I can't find the file "dbhelper.py" I don't know how to modify it thanks

comment:12 in reply to:  11 Changed 15 years ago by anonymous

Replying to anonymous:

I can't find the file "dbhelper.py" I don't know how to modify it thanks

That's because the file's inside a (compressed) .egg file.

Here's what I did:

  • checkout scrumburndown from SVN: http://trac-hacks.org/svn/scrumburndownplugin/
  • fix the file scrumburndownplugin\burndown\dbhelper.py
  • create a new .egg file: python setup.py bdist_egg
  • delete the old egg file from tracprojectroot/plugins/
  • restart trac service / webserver
  • upload the new egg file using admin plugins page

comment:13 Changed 15 years ago by paul.jurco@…

hi,

i can't get it fixed...

i have the latest svn version (dbhelper.py fixed) and i get:

File "/usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/trac/web/main.py", line 444, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/trac/web/main.py", line 205, in dispatch
  resp = chosen_handler.process_request(req)
File "build/bdist.linux-i686/egg/burndown/burndown.py", line 166, in process_requestFile "build/bdist.linux-i686/egg/burndown/burndown.py", line 233, in start_milestoneFile "build/bdist.linux-i686/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone
Other specs:
Trac: 0.11.5
Python: 2.4.3 (#1, Jan 21 2009, 01:10:13) [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)]
setuptools: 0.6c7
SQLite: 3.6.16
pysqlite: 1.1.7
Genshi: 0.5.1
mod_python: 3.2.8
Pygments: 1.0
Subversion: 1.5.5 (r34862)
jQuery:	1.2.6

comment:14 Changed 15 years ago by agonzalez@…

I can confirm this bug exists on 1.9.1 and that the patch above works.

comment:15 Changed 15 years ago by daan

Resolution: fixed
Status: newclosed

(In [6667]) Fixes #4504 (big thanks for the patch!) Created Python 2.6 egg This will be the last release to support Trac 0.10.5

comment:16 Changed 15 years ago by svdwal@…

Resolution: fixed
Status: closedreopened

This problem still exists for trac 0.11.1 and TracBurndown 1.9.2.

Trac is running on a Ubuntu 9.0.4 server, and amazingly the stack dump talks about macos 10.6. I downloaded the plugin using a mac OS snow leopard client to the server downloads folder. Maybe automatic os sniffing is not a good idea, unless there is a list of oS'es also available where I can pick the correct download by hand.

File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 423, in _dispatch_request dispatcher.dispatch(req)
File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 197, in dispatch resp = chosen_handler.process_request(req)
File "build/bdist.macosx-10.6-universal/egg/burndown/burndown.py", line 166, in process_request
File "build/bdist.macosx-10.6-universal/egg/burndown/burndown.py", line 233, in start_milestone
File "build/bdist.macosx-10.6-universal/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone

System Information:
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

Trac: 0.11.1 
Python: 2.6.2 (release26-maint, Apr 19 2009, 02:11:59) [GCC 4.3.3] 
setuptools: 0.6c9 
SQLite: 3.6.10 
pysqlite: 2.5.0 
Genshi: 0.5.1 
mod_python: 3.3.1 
Pygments: 0.10 
Subversion: 1.5.4 (r33841) 
jQuery: 1.2.6 

comment:17 Changed 15 years ago by anonymous

Priority: normalhighest

Bug still exists for me, too.

    *    File "/usr/local/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in  _dispatch_request
      Code fragment:
       445. try:
       446. if not env and env_error:
       447. raise HTTPInternalError(env_error)
       448. try:
       449. dispatcher = RequestDispatcher(env)
       450. dispatcher.dispatch(req)
       451. except RequestDone:
       452. pass
       453. resp = req._response or []
       454.  
       455. except HTTPException, e:
      Local variables:
      Name	Value
      after 	[u' except RequestDone:', u' pass', u' resp = ...
      before 	[u' try:', u' if not env and env_error:', u' raise ...
      dispatcher 	<trac.web.main.RequestDispatcher object at 0x808dd94c>
      e 	TypeError('a float is required',)
      env 	<trac.env.Environment object at 0x804f470c>
      env_error 	None
      exc_info 	(<type 'exceptions.TypeError'>, TypeError('a float is required',), ...
      filename 	'/usr/local/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main ...
      frames 	[{'function': '_dispatch_request', 'lines_before': [u' try:', u' ...
      has_admin 	True
      line 	u' dispatcher.dispatch(req)'
      lineno 	449
      message 	u'TypeError: a float is required'
      req 	<Request "GET u'/burndown'">
      resp 	[]
      tb 	<traceback object at 0x80928d9c>
      tb_hide 	None
      traceback 	u'Traceback (most recent call last):\n File ...
    * File "/usr/local/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch
      Code fragment:
       201. req.args.get('__FORM_TOKEN') != req.form_token:
       202. raise HTTPBadRequest('Missing or invalid form token. '
       203. 'Do you have cookies enabled?')
       204.  
       205. # Process the request and render the template
       206. resp = chosen_handler.process_request(req)
       207. if resp:
       208. if len(resp) == 2: # Clearsilver
       209. chrome.populate_hdf(req)
       210. template, content_type = \
       211. self._post_process_request(req, *resp)
      Local variables:
      Name	Value
      chosen_handler 	<burndown.burndown.BurndownComponent object at 0x8080b28c>
      chrome 	<trac.web.chrome.Chrome object at 0x8080b42c>
      err 	(<type 'exceptions.TypeError'>, TypeError('a float is required',), ...
      handler 	<burndown.burndown.BurndownComponent object at 0x8080b28c>
      req 	<Request "GET u'/burndown'">
      self 	<trac.web.main.RequestDispatcher object at 0x808dd94c>
    * File "build/bdist.linux-i686/egg/burndown/burndown.py", line 166, in process_request
      Local variables:
      Name	Value
      components 	[{'owner': u'matthias', 'name': u'backend_fingertracking', 'description': ...
      data 	{'milestones': [{'started': 0, 'completed': 1233852010, 'description': ...
      db 	<trac.db.pool.PooledConnection object at 0x80a1ed9c>
      empty_db_for_testing 	'false'
      milestones 	[{'started': 0, 'completed': 1233852010, 'description': u'', 'name': ...
      req 	<Request "GET u'/burndown'">
      selected_component 	u'All Components'
      selected_milestone 	{'started': None, 'completed': 0, 'description': u'\r\nMinor-Release ...
      self 	<burndown.burndown.BurndownComponent object at 0x8080b28c>
    * File "build/bdist.linux-i686/egg/burndown/burndown.py", line 233, in start_milestone
      Local variables:
      Name	Value
      db 	<trac.db.pool.PooledConnection object at 0x80a1ed9c>
      milestone 	u'2.3.0'
      self 	<burndown.burndown.BurndownComponent object at 0x8080b28c>
    * File "build/bdist.linux-i686/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone
      Local variables:
      Name	Value
      cursor 	<trac.db.util.IterableCursor object at 0x80a42dec>
      db 	<trac.db.pool.PooledConnection object at 0x80a1ed9c>
      milestone 	u'2.3.0'
      row 	(None,)

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 450, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.6-py2.5.egg/trac/web/main.py", line 206, in dispatch
  resp = chosen_handler.process_request(req)
File "build/bdist.linux-i686/egg/burndown/burndown.py", line 166, in process_requestFile "build/bdist.linux-i686/egg/burndown/burndown.py", line 233, in start_milestoneFile "build/bdist.linux-i686/egg/burndown/dbhelper.py", line 96, in get_startdate_for_milestone



Trac:  	0.11.6
Python: 	2.5.1 (r251:54863, Sep 22 2007, 01:43:31) [GCC 4.2.1 (SUSE Linux)]
setuptools: 	0.6c9
SQLite: 	3.4.1
pysqlite: 	2.3.2
Genshi: 	0.5.1
mod_python: 	3.3.1
RPC: 	1.0.6
jQuery:	1.2.6

comment:18 Changed 15 years ago by anthony.groyer@…

In fact, the issue is not really fixed.

the current dbhelper.py source code has the code: if(row and row[0]!=0 and row[0]!=0): and should be if(row and row[0] and row[0]!=0):

comment:19 Changed 14 years ago by piotr@…

Anthony,

Thanks for the tip, I just applied it to my plugin and it works perfectly. Can this be included in the trunk?

comment:20 Changed 14 years ago by mark meves

Hi, i was able to resolve this (with a sqlite database) against trac HEAD at the time of this writing with the oneline fix:

Index: burndown/dbhelper.py
===================================================================
--- burndown/dbhelper.py        (revision 8254)
+++ burndown/dbhelper.py        (working copy)
@@ -92,7 +92,7 @@
     cursor.execute("SELECT started FROM milestone WHERE name = %s", [milestone])
     row = cursor.fetchone()
 
-    if(row and row[0]!=0 and row[0]!=0):
+    if(row and row[0]!=0 and row[0]!=0 and row[0] is not None):
         return datetime.fromtimestamp(row[0])
     else:
         return None

it seems that sqlite3 returns null (None) and not 0 for timestamp values that aren't set. although someone who knows python more than me should try and resolve or comment on what looks likes a logical redundancy above.

-mark dot meves at gmail

comment:21 Changed 14 years ago by mark meves

the above comment at 01/21/10 sounds like it addresses my 'redundancy' concern any may be a more idiomatic fix.

comment:22 Changed 14 years ago by anonymous

Yeah, please include the row[0] fix. I had to manually patch it just now, and this ticket has been open needlessly for a long time.

comment:22 Changed 13 years ago by Ryan J Ollos

Resolution: fixed
Status: reopenedclosed

(In [11227]) Fixes #4504: The due date was not being checked for return of None.

comment:23 Changed 12 years ago by Ryan J Ollos

#8184 closed as a duplicate.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain daan.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.