Update:

The problem is that the code is not matching the documentation.

In the python docs for grabber (pydoc urlgrabber.grabber), the
progress_obj is clearly documented as to what arguments are supported:

      progress_obj = None
    
        a class instance that supports the following methods:
          po.start(filename, url, basename, length, text)
          # length will be None if unknown
          po.update(read) # read == bytes read so far
          po.end()


But, in the actual source shipped with natty, this is the code that calls this 
method:

    def _retrieve(self, buf):
        try:
            if not self._prog_running:
                if self.opts.progress_obj:
                    size  = self.size + self._reget_length
                    self.opts.progress_obj.start(self._prog_reportname, 
                                                 urllib.unquote(self.url), 
                                                 self._prog_basename, 
                                                 size=size,
                                                 text=self.opts.text)
                    self._prog_running = True
                    self.opts.progress_obj.update(self._amount_read)

            self._amount_read += len(buf)
            self.fo.write(buf)
            return len(buf)
        except KeyboardInterrupt:
            return -1


Note how "size" and "text" are passed as named arguments instead of positional 
arguments?

The correct code should be:

                    self.opts.progress_obj.start(self._prog_reportname, 
                                                 urllib.unquote(self.url), 
                                                 self._prog_basename, 
                                                 size,
                                                 self.opts.text)

This would correctly match the documentation.

Alternative would be to use length=size and not size=size in the code as
the documentation shows the parameter name as "length", not "size".


** Patch added: "Fix as commented in the bug"
   
https://bugs.launchpad.net/ubuntu/+source/urlgrabber/+bug/776555/+attachment/2114967/+files/bug_776555.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/776555

Title:
  KeyboardInterrupt thrown by urlgrab

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to