Skip to content

Commit

Permalink
Fix email package import for py2exe build
Browse files Browse the repository at this point in the history
Added error message and halting of torrent download when too many hash failures occur
  • Loading branch information
goatpig committed Jun 25, 2014
1 parent 03143f4 commit c709eab
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
17 changes: 16 additions & 1 deletion SDM.py
Expand Up @@ -209,14 +209,29 @@ def torrentFinished():
self.launchBitcoindAndGuardian()

#####
def torrentFailed():
def warnUserHashFail():
from PyQt4.QtGui import QMessageBox
QMessageBox.warning(self, tr('Hash Failure'), tr("""The torrent download
is currently encountering too many packet hash failures to allow it to
progress properly. As a result, the torrent engine has been halted. You
should report this incident to the Armory team and turn off this feature
until further notice."""), QMessageBox.Ok)

#####
def torrentFailed(errMsg=''):
# Not sure there's actually anything we need to do here...
if errMsg == 'hashFail':
warnUserHashFail()

bootsz = '<Unknown>'
if os.path.exists(bootfile):
bootsz = bytesToHumanSize(os.path.getsize(bootfile))

LOGERROR('Torrent failed; size of %s is %s', torrentPath, bootsz)
self.launchBitcoindAndGuardian()




TheTDM.setSecondsBetweenUpdates(90)
TheTDM.setCallback('displayFunc', torrentLogToFile)
Expand Down
15 changes: 13 additions & 2 deletions armoryengine/torrentDL.py
Expand Up @@ -57,8 +57,9 @@ def __init__(self, torrentFile=None, savePath=None, doDisable=False):
self.torrentName = None
self.savePath = None
self.savePath_temp = None



self.nHashFailures = 0
self.killAfterNHashFails = 100


#############################################################################
Expand Down Expand Up @@ -296,6 +297,9 @@ def failedFunc(self, msg=''):
#############################################################################
def errorFunc(self, errMsg):
# Use caller-set function if it exists
if 'failed hash check, re-downloading it' in errMsg:
self.nHashFailures = self.nHashFailures +1

if self.hasCustomFunc('errorFunc'):
self.customCallbacks['errorFunc'](errMsg)
return
Expand Down Expand Up @@ -323,6 +327,9 @@ def chooseFileFunc(self, default, fsize, saveas, thedir):

#############################################################################
def getTDMState(self):
if self.nHashFailures >= self.killAfterNHashFails:
return 'HashFailures'

if self.disabled:
return 'Disabled'

Expand Down Expand Up @@ -447,6 +454,10 @@ def doTheDownloadThing(self):
self.bt1dow.shutdown()
break

if self.nHashFailures >= self.killAfterNHashFails:
self.bt1dow.shutdown()
self.customCallbacks['errorFunc']('hashFail')
break

self.bt1dow.startRerequester()
self.bt1dow.autoStats()
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -4,7 +4,8 @@


opts = {"py2exe":{
"dll_excludes":["MSWSOCK.dll", "IPHLPAPI.dll", "MSWSOCK.dll", "WINNSI.dll", "WTSAPI32.dll"]
"dll_excludes":["MSWSOCK.dll", "IPHLPAPI.dll", "MSWSOCK.dll", "WINNSI.dll", "WTSAPI32.dll"],
"packages":["email"]
}}

setup( options = opts, windows = [
Expand Down

0 comments on commit c709eab

Please sign in to comment.