* fix divide by zero in `t/summary` if no transfers in list (oops)
* fix error in resume all
This commit is contained in:
Tim Wilson 2020-09-27 16:12:02 -06:00 committed by GitHub
parent 5dd6e778c0
commit af09ede67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
bot.py
View File

@ -642,7 +642,7 @@ def resume_torrents(torrents=[], reason=DEFAULT_REASON, start_all=False):
if start_all:
if not CONFIG['dryrun']:
TSCLIENT.start_all()
logger.info("Resumed: all transfers\n\tReason: {}\n\tDry run: {}".format(torrent.name, torrent.hashString, reason, CONFIG['dryrun']))
logger.info("Resumed: all transfers\n\tReason: {}\n\tDry run: {}".format(reason, CONFIG['dryrun']))
else:
for torrent in (torrents if len(torrents) > 0 else TSCLIENT.get_torrents()):
if torrent.status == "stopped":
@ -1331,9 +1331,9 @@ def torSummary(torrents, repeat_msg_key=None, show_repeat=True):
totDown = humanbytes(sumDown)
totUp = humanbytes(sumUp)
totRatio = '{:.2f}'.format(sumUp / sumDown)
totRatio = '{:.2f}'.format((sumUp / sumDown) if sumDown > 0 else 0)
totDownRatio = '{:.2f}'.format(sumDown / sumTot * 100.0)
totDownRatio = '{:.2f}'.format((sumDown / sumTot * 100.0) if sumTot > 0 else 0)
numTopRatios = min([len(torrents),CONFIG['summary_num_top_ratio']])
topRatios = "• Top {} ratio{}:".format(numTopRatios,"s" if numTopRatios != 1 else "")
@ -1945,10 +1945,6 @@ async def modify(message, content=""):
embed.set_author(name="No matching transfers found!", icon_url=CONFIG['logo_url'])
embeds = [embed]
else:
try:
await message.delete()
except:
pass
ops = ["pauseall","resumeall"]
opNames = ["pause all","resume all"]
opEmoji = ['','▶️']