Ensure an integer for chunk_count.

Review Request #180 — Created April 7, 2014 and submitted

jsirois
pants
jsirois/fetcher
22
pants-reviews
benjyw, patricklaw, tejal
commit 9c1ed832f77d632bdf4c17ca8150bb4b9896c759
Author: John Sirois <jsirois@twitter.com>
Date:   Sat Apr 5 11:50:43 2014 -0600

    Ensure an integer for chunk_count.

 src/python/pants/net/http/fetcher.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Before:
$ rm -rf ~/.pants.d/tools/
$ PANTS_DEV=1 ./pants goal resolve 3rdparty:guava
*** Running pants in dev mode from src/python/pants/bin/pants_exe.py ***

09:40:48 00:00 [main]
               See a report at: http://localhost:45431/run/pants_run_2014_04_07_09_40_48_129
09:40:48 00:00   [setup]
09:40:48 00:00     [bootstrap]
09:40:48 00:00     [parse]
09:40:48 00:00   [bootstrap]
09:40:48 00:00     [bootstrap-jvm-tools]
09:40:48 00:00   [gen]
09:40:48 00:00     [thrift]
09:40:48 00:00     [scrooge]
09:40:48 00:00     [protoc]
09:40:48 00:00     [antlr]
09:40:48 00:00   [check-exclusives]
09:40:48 00:00     [check-exclusives]
09:40:48 00:00   [resolve]
  2% :48 00:00     [ivy]
               FAILURE
Traceback (most recent call last):
  File "src/python/pants/bin/pants_exe.py", line 188, in <module>
    main()
  File "src/python/pants/bin/pants_exe.py", line 182, in main
    _run()
  File "src/python/pants/bin/pants_exe.py", line 165, in _run
    result = command.run(lock)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/commands/goal.py", line 473, in run
    return Goal._execute(context, self.phases, print_timing=self.options.time)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/commands/goal.py", line 255, in _execute
    return engine.execute(context, phases)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/engine/engine.py", line 182, in execute
    self.attempt(timer, context, phases)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/engine/group_engine.py", line 281, in attempt
    phase_executor.attempt(timer, explain)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/engine/group_engine.py", line 172, in attempt
    execute_task(goal, self._tasks_by_goal[goal], self._context.targets())
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/engine/group_engine.py", line 143, in execute_task
    task.execute(targets)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/tasks/ivy_resolve.py", line 123, in execute
    workunit_name='ivy-resolve')
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/tasks/task.py", line 341, in ivy_resolve
    bootstrap_workunit_factory=self.context.new_workunit)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/ivy/bootstrapper.py", line 76, in default_ivy
    bootstrap_workunit_factory=bootstrap_workunit_factory)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/ivy/bootstrapper.py", line 95, in ivy
    return Ivy(self._get_classpath(java_executor, bootstrap_workunit_factory),
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/ivy/bootstrapper.py", line 106, in _get_classpath
    self._classpath = self._bootstrap_ivy_classpath(executor, workunit_factory)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/ivy/bootstrapper.py", line 145, in _bootstrap_ivy_classpath
    ivy = self._bootstrap_ivy(os.path.join(ivy_bootstrap_dir, 'bootstrap.jar'))
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/ivy/bootstrapper.py", line 180, in _bootstrap_ivy
    timeout=self._timeout)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/net/http/fetcher.py", line 280, in download
    self.fetch(url, listener, chunk_size=chunk_size, timeout=timeout)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/net/http/fetcher.py", line 244, in fetch
    listener.recv_chunk(data)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/net/http/fetcher.py", line 88, in recv_chunk
    listener.recv_chunk(data)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/net/http/fetcher.py", line 89, in recv_chunk
    self.recv_chunk(data)
  File "/home/jsirois/dev/3rdparty/pantsbuild-pants/src/python/pants/net/http/fetcher.py", line 190, in recv_chunk
    sys.stdout.write('.' * self.chunks)
TypeError: can't multiply sequence by non-int of type 'float'



After:
$ PANTS_DEV=1 ./pants goal resolve 3rdparty:guava
*** Running pants in dev mode from src/python/pants/bin/pants_exe.py ***

09:41:00 00:00 [main]
               See a report at: http://localhost:45431/run/pants_run_2014_04_07_09_41_00_415
09:41:00 00:00   [setup]
09:41:00 00:00     [bootstrap]
09:41:00 00:00     [parse]
09:41:00 00:00   [bootstrap]
09:41:00 00:00     [bootstrap-jvm-tools]
09:41:00 00:00   [gen]
09:41:00 00:00     [thrift]
09:41:00 00:00     [scrooge]
09:41:00 00:00     [protoc]
09:41:00 00:00     [antlr]
09:41:00 00:00   [check-exclusives]
09:41:00 00:00     [check-exclusives]
09:41:00 00:00   [resolve]
100% .................................................. 1193 KB 1.126s

09:41:01 00:01       [ivy-bootstrap]
               SUCCESS
PA
  1. 
      
  2. src/python/pants/net/http/fetcher.py (Diff revision 1)
     
     
    `self.read // self.chunk_size`
    1. Oops, I didn't notice that's what you changed it from.  Why?
    2. $ python2.6
      Python 2.6.8 (unknown, Jul 15 2013, 01:30:32) 
      [GCC 4.7.3] on linux3
      Type "help", "copyright", "credits" or "license" for more information.
      >>> 3//1.0
      3.0
      >>> '*' * 3//1.0
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: unsupported operand type(s) for //: 'str' and 'float'
      >>> 
      
    3. $ python2.6
      Python 2.6.8 (unknown, Aug 25 2013, 00:04:29)
      [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from __future__ import division
      >>> 1 // 2
      0
    4. Oops, I skimmed that too fast, sorry!  Ignore me!
  3. 
      
PA
  1. Ship It!
  2. 
      
JS
  1. Thanks - merged.
  2. 
      
JS
Review request changed

Status: Closed (submitted)

Loading...