performance improvements

added labeling to multi-message output for `t/list` and `t/modify` (e.g. message 1 of 2)
Played with the output of `t/list` and `t/modify` to make it a bit easier to interpret
This commit is contained in:
Tim Wilson 2020-09-09 17:35:29 -06:00 committed by GitHub
parent 53e43a4dcd
commit 55ae0bb6f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
bot.py
View File

@ -1462,13 +1462,13 @@ def torList(torrents, author_name="Torrent Transfers",title=None,description=Non
down = humanbytes(t.progress * 0.01 * t.totalSize) down = humanbytes(t.progress * 0.01 * t.totalSize)
out = "{}{}{}{} ".format(stateEmoji[t.status],errorStrs[t.error],'🚀' if t.rateDownload + t.rateUpload > 0 else '🐢' if t.isStalled else '🐇', '🔐' if t.isPrivate else '🔓') out = "{}{}{}{} ".format(stateEmoji[t.status],errorStrs[t.error],'🚀' if t.rateDownload + t.rateUpload > 0 else '🐢' if t.isStalled else '🐇', '🔐' if t.isPrivate else '🔓')
if t.status == 'downloading': if t.status == 'downloading':
out += "{}/{} ({:.1f}%) {}⬇️ {}/s ⬆️ *{}/s* ⚖️ *{:.2f}*".format(down,humanbytes(t.totalSize),t.progress, '' if eta <= 0 else '\n{} @ '.format(humanseconds(eta)), humanbytes(t.rateDownload),humanbytes(t.rateUpload),t.uploadRatio) out += "{:.1f}% of {}{} {}/s ⬇️ *{}/s* ⬆️ *{:.2f}* ⚖️".format(t.progress, humanbytes(t.totalSize, d=1), '' if eta <= 0 else '{} @ '.format(humanseconds(eta)), humanbytes(t.rateDownload), humanbytes(t.rateUpload), t.uploadRatio)
elif t.status == 'seeding': elif t.status == 'seeding':
out += "{} ⬆️ *{}/s* ⚖️ *{:.2f}*".format(humanbytes(t.totalSize),humanbytes(t.rateUpload),t.uploadRatio) out += "{} ⏬ *{}/s* ⬆️ *{:.2f}* ⚖️".format(humanbytes(t.totalSize, d=1), humanbytes(t.rateUpload), t.uploadRatio)
elif t.status == 'stopped': elif t.status == 'stopped':
out += "{}/{} ({:.1f}%) ⚖️ *{:.2f}*".format(down,humanbytes(t.totalSize),t.progress,t.uploadRatio) out += "{:.1f}% of {} ⏬ *{:.2f}* ⚖️".format(t.progress, humanbytes(t.totalSize, d=1), t.uploadRatio)
elif t.status == 'finished': elif t.status == 'finished':
out += "{} ⚖️ {:.2f}".format(humanbytes(t.totalSize),t.uploadRatio) out += "{}{:.2f} ⚖️".format(humanbytes(t.totalSize, d=1), t.uploadRatio)
elif t.status == "checking": elif t.status == "checking":
out += "{:.2f}%".format(t.recheckProgress*100.0) out += "{:.2f}%".format(t.recheckProgress*100.0)
@ -1484,16 +1484,19 @@ def torList(torrents, author_name="Torrent Transfers",title=None,description=Non
n = 0 n = 0
i = 0 i = 0
eNum = 1
eNumTotal = 1 + len(torrents) // 25
embeds = [] embeds = []
if len(torrents) > 0: if len(torrents) > 0:
while i < len(torrents): while i < len(torrents):
embed=discord.Embed(title=title,description=description,color=0xb51a00) embed=discord.Embed(title=title + ('' if eNumTotal == 1 else ' ({} of {})'.format(eNum, eNumTotal)),description=description,color=0xb51a00)
for j in range(25): for j in range(25):
embed.add_field(name=nameList[i],value=valList[i],inline=False) embed.add_field(name=nameList[i],value=valList[i],inline=False)
i += 1 i += 1
n += 1 n += 1
if n >= 25: if n >= 25:
n = 0 n = 0
eNum += 1
break break
if i >= len(torrents): if i >= len(torrents):
break break