Skip to content

Commit

Permalink
progress window now terminates correctly after downloaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
debugdom committed Jan 11, 2010
1 parent d00ee7f commit 214ec10
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions mayaAutoUpdateFramework/mayaToolAutoUpdateFramework.py
Expand Up @@ -10,7 +10,6 @@ class MayaUpdateGUI:

#class variables


def __init__(self, latestVersionNumber, productName, bugFixes, newFeatures, downloadURL):

self.preferenceFileName = "mayaUpdatePrefs.prefs"
Expand Down Expand Up @@ -65,27 +64,43 @@ def currentLocation(self):

class updateDownloadSystem():

def _reporthook(self, numblocks, blocksize, filesize, url=None):

def reporthook(self, numblocks, blocksize, filesize, url=None):



fileName = os.path.basename(url)

percent = min((numblocks*blocksize*100)/filesize, 100)

cmds.progressWindow(title='Downloading', progress=percent, status='Downloading: ', isInterruptable=True)

if(percent == 100):
cmds.progressWindow(endProgress=True)
else:
cmds.progressWindow(edit=True, title='Downloaded', progress=percent, status=('Downloading: ' + str(percent) + '%' ))

try:

'''try:
percent = min((numblocks*blocksize*100)/filesize, 100)
cmds.progressWindow(title='Download', progress=percent, status='Downloading: ', isInterruptable=True)
cmds.progressWindow(title='Downloading', progress=percent, status='Downloading: ', isInterruptable=True)
#cmds.progressWindow(endProgress=True)
except:
percent = 100
cmds.progressWindow(endProgress=1)
cmds.progressWindow(isCancelled=True)
if numblocks != 0:
cmds.progressWindow(edit=True, progress=percent, status=('Downloading: ' + str(percent) + '%' ))

#cmds.progressWindow(edit=True, title='Downloaded', progress=percent, status=('Downloading: ' + str(percent) + '%' ))
cmds.progressWindow(endProgress=True)
'''

def geturl(self, url, dst):

urllib.urlretrieve(url, dst,
lambda nb, bs, fs, url=url: self._reporthook(nb,bs,fs,url))
lambda nb, bs, fs, url=url: self.reporthook(nb,bs,fs,url))

class MayaToolAutoUpdater:

""" checks online for updated version from XML file """

currentRunningVersion = ""
Expand Down Expand Up @@ -164,7 +179,7 @@ def getUpdateInformation(self):

except IOError:

print "IO Error: Cannot to connect to 'tinternet."
sys.stderr.write("IO Error: Cannot to connect to 'tinternet.")

def currentLocation(self):
currentDir = os.path.dirname(locationMarker.__file__)
Expand Down Expand Up @@ -195,7 +210,6 @@ def parseFeed(self):




#goGetUpdate = MayaToolAutoUpdater("AudioAmpExtractor", "0.8a", "http://update.reality-debug.co.uk/audioAmpExtractor.xml")

#goGetUpdate.userQueriesUpdate()
if __name__ == '__main__':
goGetUpdate = MayaToolAutoUpdater("AudioAmpExtractor", "0.8a", "http://update.reality-debug.co.uk/audioAmpExtractor.xml")
#goGetUpdate.userQueriesUpdate()

0 comments on commit 214ec10

Please sign in to comment.