add progress-hook to HTTPConnection

Bug #239684 reported by Markus Korn on 2008-06-13
4
Affects Status Importance Assigned to Milestone
python-launchpad-bugs
Undecided
Unassigned

Bug Description

It would be nice if the user of py-lp-bugs can get information about the progess of an http operation.

Markus Korn (thekorn) wrote :

this patch against .main r94 adds a basic hook-interface to py-lp-bugs.

This is an example on how to use this progress_hook:

In [1]: def example_hook(counter, block_size, size):
   ...: print (counter, block_size, size)
   ...:
   ...:

In [2]: from launchpadbugs.connector import ConnectBug

In [3]: Bug = ConnectBug()

In [4]: Bug.connection.set_progress_hook(example_hook)

In [5]: b = Bug(200500)
(1, 4096, 51781)
(2, 4096, 51781)
(3, 4096, 51781)
(4, 4096, 51781)
(5, 4096, 51781)
(6, 4096, 51781)
(7, 4096, 51781)
(8, 4096, 51781)
(9, 4096, 51781)
(10, 4096, 51781)
(11, 4096, 51781)
(12, 4096, 51781)
(13, 4096, 51781)

Please review this patch, it definitely needs some texting

Markus

Markus Korn (thekorn) wrote :

fixed closing the socket and getting the redirected url

Stephan Ruegamer (sadig) wrote :

Markus,

the progress_hook works nice :) Thx...

I think you can commit this to trunk...

Thx a lot :)
\sh

Stephan Ruegamer (sadig) wrote :

hi Markus,

I encountered a bug:

The counter is not correct...

First:

e.g. http://launchpad.net/~shermann/+assignedbugs -> 8 bugs are listed
#!/usr/bin/python

import launchpadbugs.connector as Connector
import launchpadbugs.html_bug

BugList = Connector.ConnectBugList()
Bug = Connector.ConnectBug(method="Text")
l=BugList("https://edge.launchpad.net/~shermann/+assignedbugs")
for i in l.bugs:
        b=Bug(i)
        print "%8d | %80s | %40s" % (i.bugnumber , i.summary, b.tags)

=> brings you 7 bugs only

and the progress counter will give you 6 ;)

I think there are two bugs here...and I don't know if it's in the very same http_connection.py :)

\sh

Markus Korn (thekorn) wrote :

Hi Stephan,
in your case BugList returns a set of all bugs where you are assigned to at least one task, if you want all tasks, please use:
BugList = ConnectBugList(all_tasks=True)

the second issue with the counter of the progress_hook is maybe about a different understanding of its functionality: the progress_hook does not care about the content of the HTTPConnection but about its size, so 6 here means py-lp-bugs loaded a page with the size of ~6x4096 bytes.

Markus

Stephan Ruegamer (sadig) wrote :

Hi Markus,

yeah...sometimes I should trust my feelings ;)

Ok...but it means also, that everytime a new page is being retrieved the counter will be set back to 1.

I wonder if it's possible to implement a progress_hook as well in the parsing of the bug pages (bug lists..)

Anyways...this is a good start for the UI...thx a lot...the behaviour works brilliant...I think you can commit it :)

Regards,

\sh

Markus Korn (thekorn) wrote :

------------------------------------------------------------
revno: 96
committer: Markus Korn <email address hidden>
branch nick: main
timestamp: Sat 2008-06-14 09:38:17 +0200
message:
  launchpadbugs/http_connection.py: added progress_hook to
  HTTPConnnection (LP: #239684)
------------------------------------------------------------

Changed in python-launchpad-bugs:
status: New → Fix Committed
Markus Korn (thekorn) wrote :

Fix released in py-lp-bugs 0.3

Changed in python-launchpad-bugs:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers