Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] KeyError: 'ratio' (in DownloadWidgetItem.__lt__) #8026

Closed
kozlovsky opened this issue May 13, 2024 · 0 comments · Fixed by #8027
Closed

[main] KeyError: 'ratio' (in DownloadWidgetItem.__lt__) #8026

kozlovsky opened this issue May 13, 2024 · 0 comments · Fixed by #8027
Assignees

Comments

@kozlovsky
Copy link
Contributor

The error appears when right-clicking on the RATIO column's header in the downloads pane.

Traceback (most recent call last):
  File "C:\\dev\\tribler\\src\\tribler\\gui\\widgets\\downloadwidgetitem.py", line 132, in __lt__
    return float(self.download_info["ratio"]) > float(other.download_info["ratio"])
KeyError: 'ratio'

Here:

    def __lt__(self, other):
        # The download info might not be available yet or there could still be loading QTreeWidgetItem
        if not self.download_info or not isinstance(other, DownloadWidgetItem):
            return True
        elif not other.download_info:
            return False

        column = self.treeWidget().sortColumn()
        if column == 1:
            return float(self.download_info["size"]) > float(other.download_info["size"])
        elif column == 2:
            return int(self.download_info["progress"] * 100) > int(other.download_info["progress"] * 100)
        elif column == 4:
            return self.download_info["num_seeds"] > other.download_info["num_seeds"]
        elif column == 5:
            return self.download_info["num_peers"] > other.download_info["num_peers"]
        elif column == 6:
            return float(self.download_info["speed_down"]) > float(other.download_info["speed_down"])
        elif column == 7:
            return float(self.download_info["speed_up"]) > float(other.download_info["speed_up"])
        elif column == 8:
            return float(self.download_info["ratio"]) > float(other.download_info["ratio"])  # <-- here

The reason for the error is renaming the "ratio" dictionary field to all_time_ratio in #7817. We need to rename it here as well.

@kozlovsky kozlovsky self-assigned this May 13, 2024
kozlovsky added a commit to kozlovsky/tribler that referenced this issue May 13, 2024
kozlovsky added a commit to kozlovsky/tribler that referenced this issue May 22, 2024
kozlovsky added a commit that referenced this issue May 22, 2024
…error

Fix #8026 KeyError when sorting by the RATIO column
@drew2a drew2a added this to the 7.15.0 milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants