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

[FIX] errorreporting: Remove use of pip internal api #2724

Merged
merged 2 commits into from
Oct 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Orange/canvas/application/errorreporting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import pip
import sys
import time
import logging
Expand All @@ -16,6 +15,8 @@
from urllib.request import pathname2url, urlopen, build_opener
from unittest.mock import patch

import pkg_resources

from AnyQt.QtCore import pyqtSlot, QSettings, Qt
from AnyQt.QtGui import QDesktopServices, QFont
from AnyQt.QtWidgets import (
Expand All @@ -38,6 +39,17 @@ class OWWidget: pass
log = logging.getLogger()


def get_installed_distributions():
for dist in pkg_resources.working_set: # type: pkg_resources.Distribution
name = dist.project_name
try:
version = dist.version
except ValueError:
# PKG-INFO/METADATA is not available or parsable.
version = "Unknown"
yield "{name}=={version}".format(name=name, version=version)


class ErrorReporting(QDialog):
_cache = set() # For errors already handled during one session

Expand Down Expand Up @@ -190,8 +202,7 @@ def _find_widget_frame(tb):
widget = frame.tb_frame.f_locals['self'].__class__
widget_module = '{}:{}'.format(widget.__module__, frame.tb_lineno)

packages = ', '.join(sorted("%s==%s" % (i.project_name, i.version)
for i in pip.get_installed_distributions()))
packages = ', '.join(sorted(get_installed_distributions()))

machine_id = QSettings().value('error-reporting/machine-id', '', type=str)

Expand Down