keeleysam / instadmg

Automatically exported from code.google.com/p/instadmg
0 stars 0 forks source link

InstaUp2Date download with unknown length causes float division exception #94

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run InstaUp2Date with 10.6_vanilla behind a TMG firewall.
2. The firewall returns an unknown length while it's scanning the 10.6.8 v1.1 
combo update for malware.
3. displayTools.statusHandler._progressPercentage crashes as it doesn't 
correctly handle a float value of 0.0 for _expectedLength, only expecting 
integer 0 or None.

What is the expected output? What do you see instead?

    Mac OS X 10.6.8 Combo Update v1.1 - checksumming: Traceback (most recent call last):
  File "AddOns/InstaUp2Date/instaUp2Date.py", line 716, in <module>
    main()
  File "AddOns/InstaUp2Date/instaUp2Date.py", line 671, in main
    thisController.findItems()
  File "AddOns/InstaUp2Date/instaUp2Date.py", line 330, in findItems
    thisItem.findItem(progressReporter=progressReporter)
  File "/Users/Shared/instadmg/AddOns/InstaUp2Date/Resources/installerPackage.py", line 158, in findItem
  File "/Users/Shared/instadmg/AddOns/InstaUp2Date/Resources/cacheController.py", line 256, in findItem
  File "/Users/Shared/instadmg/AddOns/InstaUp2Date/Resources/cacheController.py", line 533, in findItemInCaches
  File "/Users/Shared/instadmg/AddOns/InstaUp2Date/Resources/checksum.py", line 272, in checksum

  File "/Users/Shared/DAFGU/instadmg/AddOns/InstaUp2Date/Resources/displayTools.py", line 174, in update
    'progressPercentage' : self._progressPercentage(),
  File "/Users/Shared/DAFGU/instadmg/AddOns/InstaUp2Date/Resources/displayTools.py", line 75, in _progressPercentage
    return (float(self._value)/float(self._expectedLength)) * 100
ZeroDivisionError: float division
dafgu.catalog failed with exit code 1

What version of InstaDMG are you running? What revision number (this should
be the second line of your package log)?

svn 426

What OS are you running on (booted from)?

10.6.8

What OS are you installing?

10.6.8

Please provide any additional information below.

Patch that tests _expectedLength with equality to 0, which is also true for 
0.0, and not identity with 0, which is false for 0.0.

Index: AddOns/InstaUp2Date/Resources/displayTools.py
===================================================================
--- AddOns/InstaUp2Date/Resources/displayTools.py   (revision 426)
+++ AddOns/InstaUp2Date/Resources/displayTools.py   (working copy)
@@ -66,7 +66,7 @@
    def _progressPercentage(self):
        '''Return the progress as a percentage of the total'''

-       if self._expectedLength is None or self._expectedLength is 0:
+       if self._expectedLength is None or self._expectedLength == 0:
            return 0

        if self._value is None:

Original issue reported on code.google.com by MagerV...@gmail.com on 22 Aug 2011 at 8:46

GoogleCodeExporter commented 9 years ago
While it would be difficult for me to reproduce, I'll get it in my local test 
branch and if I don't see any conflicts I'll check it in Thurs/Fri, pending 
other patches being released this week.  

Original comment by allister...@gtempaccount.com on 22 Aug 2011 at 1:42