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

Plugin manager gives traceback if no internet connection #26

Closed
psobolewskiPhD opened this issue Feb 17, 2024 · 0 comments · Fixed by napari/napari#6931
Closed

Plugin manager gives traceback if no internet connection #26

psobolewskiPhD opened this issue Feb 17, 2024 · 0 comments · Fixed by napari/napari#6931
Assignees
Labels
bug Something isn't working UX/UI

Comments

@psobolewskiPhD
Copy link
Member

psobolewskiPhD commented Feb 17, 2024

If you open the Plugin Manager without an internet connection your get a traceback in the terminal.

URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

Instead, a notification should be used to inform the user that they cannot install remote plugins, only local ones.

Full traceback:

---------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:1348, in AbstractHTTPHandler.do_open(self=<urllib.request.HTTPSHandler object>, http_class=<class 'http.client.HTTPSConnection'>, req=<urllib.request.Request object>, **http_conn_args={'check_hostname': None, 'context': None})
   1347 try:
-> 1348     h.request(req.get_method(), req.selector, req.data, headers,
        h = <http.client.HTTPSConnection object at 0x2948faf10>
        headers = {'Host': 'npe2api.vercel.app', 'User-Agent': 'napari/0.5.0a2.dev543+gad78ee21a runtime/python CPython/3.11.7 Darwin/22.4.0', 'Connection': 'close'}
        req = <urllib.request.Request object at 0x2948e6510>
        req.selector = '/api/conda'
   1349               encode_chunked=req.has_header('Transfer-encoding'))
   1350 except OSError as err: # timeout error

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:1294, in HTTPConnection.request(self=<http.client.HTTPSConnection object>, method='GET', url='/api/conda', body=None, headers={'Connection': 'close', 'Host': 'npe2api.vercel.app', 'User-Agent': 'napari/0.5.0a2.dev543+gad78ee21a runtime/python CPython/3.11.7 Darwin/22.4.0'}, encode_chunked=False)
   1293 """Send a complete request to the server."""
-> 1294 self._send_request(method, url, body, headers, encode_chunked)
        method = 'GET'
        url = '/api/conda'
        body = None
        headers = {'Host': 'npe2api.vercel.app', 'User-Agent': 'napari/0.5.0a2.dev543+gad78ee21a runtime/python CPython/3.11.7 Darwin/22.4.0', 'Connection': 'close'}
        encode_chunked = False
        self = <http.client.HTTPSConnection object at 0x2948faf10>

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:1340, in HTTPConnection._send_request(self=<http.client.HTTPSConnection object>, method='GET', url='/api/conda', body=None, headers={'Connection': 'close', 'Host': 'npe2api.vercel.app', 'User-Agent': 'napari/0.5.0a2.dev543+gad78ee21a runtime/python CPython/3.11.7 Darwin/22.4.0'}, encode_chunked=False)
   1339     body = _encode(body, 'body')
-> 1340 self.endheaders(body, encode_chunked=encode_chunked)
        encode_chunked = False
        body = None
        self = <http.client.HTTPSConnection object at 0x2948faf10>

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:1289, in HTTPConnection.endheaders(self=<http.client.HTTPSConnection object>, message_body=None, encode_chunked=False)
   1288     raise CannotSendHeader()
-> 1289 self._send_output(message_body, encode_chunked=encode_chunked)
        message_body = None
        self = <http.client.HTTPSConnection object at 0x2948faf10>
        encode_chunked = False

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:1048, in HTTPConnection._send_output(self=<http.client.HTTPSConnection object>, message_body=None, encode_chunked=False)
   1047 del self._buffer[:]
-> 1048 self.send(msg)
        msg = b'GET /api/conda HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: npe2api.vercel.app\r\nUser-Agent: napari/0.5.0a2.dev543+gad78ee21a runtime/python CPython/3.11.7 Darwin/22.4.0\r\nConnection: close\r\n\r\n'
        self = <http.client.HTTPSConnection object at 0x2948faf10>
   1050 if message_body is not None:
   1051 
   1052     # create a consistent interface to message_body

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:986, in HTTPConnection.send(self=<http.client.HTTPSConnection object>, data=b'GET /api/conda HTTP/1.1\r\nAccept-Encoding: id....11.7 Darwin/22.4.0\r\nConnection: close\r\n\r\n')
    985 if self.auto_open:
--> 986     self.connect()
        self = <http.client.HTTPSConnection object at 0x2948faf10>
    987 else:

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:1459, in HTTPSConnection.connect(self=<http.client.HTTPSConnection object>)
   1457 "Connect to a host on a given (SSL) port."
-> 1459 super().connect()
   1461 if self._tunnel_host:

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py:952, in HTTPConnection.connect(self=<http.client.HTTPSConnection object>)
    951 sys.audit("http.client.connect", self, self.host, self.port)
--> 952 self.sock = self._create_connection(
        self.sock = None
        self = <http.client.HTTPSConnection object at 0x2948faf10>
        self._create_connection = <function create_connection at 0x101b72f20>
        self.host = 'npe2api.vercel.app'
        self.port = 443
        (self.host,self.port) = ('npe2api.vercel.app', 443)
        self.timeout = <object object at 0x101139920>
        self.source_address = None
    953     (self.host,self.port), self.timeout, self.source_address)
    954 # Might fail in OSs that don't implement TCP_NODELAY

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/socket.py:827, in create_connection(address=('npe2api.vercel.app', 443), timeout=<object object>, source_address=None, all_errors=False)
    826 exceptions = []
--> 827 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
        host = 'npe2api.vercel.app'
        port = 443
        SOCK_STREAM = <SocketKind.SOCK_STREAM: 1>
    828     af, socktype, proto, canonname, sa = res

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/socket.py:962, in getaddrinfo(host='npe2api.vercel.app', port=443, family=0, type=<SocketKind.SOCK_STREAM: 1>, proto=0, flags=0)
    961 addrlist = []
--> 962 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
        host = 'npe2api.vercel.app'
        port = 443
        family = 0
        type = <SocketKind.SOCK_STREAM: 1>
        proto = 0
        flags = 0
    963     af, socktype, proto, canonname, sa = res

gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/site-packages/superqt/utils/_qthreading.py:617, in create_worker.<locals>.reraise(e=URLError(gaierror(8, 'nodename nor servname provided, or not known')))
    616 def reraise(e):
--> 617     raise e
        e = URLError(gaierror(8, 'nodename nor servname provided, or not known'))

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/site-packages/superqt/utils/_qthreading.py:178, in WorkerBase.run(self=<napari._qt.qthreading.GeneratorWorker object>)
    176     warnings.filterwarnings("always")
    177     warnings.showwarning = lambda *w: self.warned.emit(w)
--> 178     result = self.work()
        self = <napari._qt.qthreading.GeneratorWorker object at 0x2913e6830>
    179 if isinstance(result, Exception):
    180     if isinstance(result, RuntimeError):
    181         # The Worker object has likely been deleted.
    182         # A deleted wrapped C/C++ object may result in a runtime
    183         # error that will cause segfault if we try to do much other
    184         # than simply notify the user.

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/site-packages/superqt/utils/_qthreading.py:444, in GeneratorWorker.work(self=<napari._qt.qthreading.GeneratorWorker object>)
    442 try:
    443     _input = self._next_value()
--> 444     output = self._gen.send(_input)
        self = <napari._qt.qthreading.GeneratorWorker object at 0x2913e6830>
        _input = None
        self._gen = <generator object iter_napari_plugin_info at 0x291388b80>
    445     self.yielded.emit(output)
    446 except StopIteration as exc:

File ~/Dev/napari/napari/plugins/npe2api.py:93, in iter_napari_plugin_info()
     90     data = executor.submit(plugin_summaries)
     91     _conda = executor.submit(conda_map)
---> 93 conda = _conda.result()
        _conda = <Future at 0x2948e6c10 state=finished raised URLError>
     94 conda_set = {normalized_name(x) for x in conda}
     95 for info in data.result():

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/concurrent/futures/_base.py:449, in Future.result(self=None, timeout=None)
    447     raise CancelledError()
    448 elif self._state == FINISHED:
--> 449     return self.__get_result()
        self = None
    451 self._condition.wait(timeout)
    453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self=None)
    399 if self._exception:
    400     try:
--> 401         raise self._exception
        self = None
    402     finally:
    403         # Break a reference cycle with the exception in self._exception
    404         self = None

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/concurrent/futures/thread.py:58, in _WorkItem.run(self=None)
     55     return
     57 try:
---> 58     result = self.fn(*self.args, **self.kwargs)
        self = None
     59 except BaseException as exc:
     60     self.future.set_exception(exc)

File ~/Dev/napari/napari/plugins/npe2api.py:83, in conda_map()
     81 """Return map of PyPI package name to conda_channel/package_name ()."""
     82 url = "https://npe2api.vercel.app/api/conda"
---> 83 with urlopen(Request(url, headers={'User-Agent': _user_agent()})) as resp:
        url = 'https://npe2api.vercel.app/api/conda'
        _user_agent = <functools._lru_cache_wrapper object at 0x2886e9c70>
     84     return json.load(resp)

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:216, in urlopen(url=<urllib.request.Request object>, data=None, timeout=<object object>, cafile=None, capath=None, cadefault=False, context=None)
    214 else:
    215     opener = _opener
--> 216 return opener.open(url, data, timeout)
        opener = <urllib.request.OpenerDirector object at 0x2948f8a90>
        url = <urllib.request.Request object at 0x2948e6510>
        data = None
        timeout = <object object at 0x101139920>

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:519, in OpenerDirector.open(self=<urllib.request.OpenerDirector object>, fullurl=<urllib.request.Request object>, data=None, timeout=<object object>)
    516     req = meth(req)
    518 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 519 response = self._open(req, data)
        req = <urllib.request.Request object at 0x2948e6510>
        data = None
        self = <urllib.request.OpenerDirector object at 0x2948f8a90>
    521 # post-process response
    522 meth_name = protocol+"_response"

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:536, in OpenerDirector._open(self=<urllib.request.OpenerDirector object>, req=<urllib.request.Request object>, data=None)
    533     return result
    535 protocol = req.type
--> 536 result = self._call_chain(self.handle_open, protocol, protocol +
        result = None
        protocol = 'https'
        self.handle_open = {'unknown': [<urllib.request.UnknownHandler object at 0x2948fac50>], 'http': [<urllib.request.HTTPHandler object at 0x17de139d0>], 'ftp': [<urllib.request.FTPHandler object at 0x2948f8710>], 'file': [<urllib.request.FileHandler object at 0x2948f8f90>], 'data': [<urllib.request.DataHandler object at 0x2948f9210>], 'https': [<urllib.request.HTTPSHandler object at 0x2948f9a90>]}
        protocol +
                                  '_open' = 'https_open'
        self = <urllib.request.OpenerDirector object at 0x2948f8a90>
        req = <urllib.request.Request object at 0x2948e6510>
    537                           '_open', req)
    538 if result:
    539     return result

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:496, in OpenerDirector._call_chain(self=<urllib.request.OpenerDirector object>, chain={'data': [<urllib.request.DataHandler object>], 'file': [<urllib.request.FileHandler object>], 'ftp': [<urllib.request.FTPHandler object>], 'http': [<urllib.request.HTTPHandler object>], 'https': [<urllib.request.HTTPSHandler object>], 'unknown': [<urllib.request.UnknownHandler object>]}, kind='https', meth_name='https_open', *args=(<urllib.request.Request object>,))
    494 for handler in handlers:
    495     func = getattr(handler, meth_name)
--> 496     result = func(*args)
        func = <bound method HTTPSHandler.https_open of <urllib.request.HTTPSHandler object at 0x2948f9a90>>
        args = (<urllib.request.Request object at 0x2948e6510>,)
    497     if result is not None:
    498         return result

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:1391, in HTTPSHandler.https_open(self=<urllib.request.HTTPSHandler object>, req=<urllib.request.Request object>)
   1390 def https_open(self, req):
-> 1391     return self.do_open(http.client.HTTPSConnection, req,
        req = <urllib.request.Request object at 0x2948e6510>
        self = <urllib.request.HTTPSHandler object at 0x2948f9a90>
        http.client = <module 'http.client' from '/Users/piotrsobolewski/Dev/miniforge3/envs/napari-dev/lib/python3.11/http/client.py'>
        self._context = None
        self._check_hostname = None
   1392         context=self._context, check_hostname=self._check_hostname)

File ~/Dev/miniforge3/envs/napari-dev/lib/python3.11/urllib/request.py:1351, in AbstractHTTPHandler.do_open(self=<urllib.request.HTTPSHandler object>, http_class=<class 'http.client.HTTPSConnection'>, req=<urllib.request.Request object>, **http_conn_args={'check_hostname': None, 'context': None})
   1348         h.request(req.get_method(), req.selector, req.data, headers,
   1349                   encode_chunked=req.has_header('Transfer-encoding'))
   1350     except OSError as err: # timeout error
-> 1351         raise URLError(err)
   1352     r = h.getresponse()
   1353 except:

URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

@psobolewskiPhD psobolewskiPhD added bug Something isn't working UX/UI labels Feb 17, 2024
@goanpeca goanpeca self-assigned this May 23, 2024
jni pushed a commit to napari/napari that referenced this issue May 27, 2024
…ng the plugin manager (#6931)

Fixes napari/napari-plugin-manager#26

# Description

Catches connectivity errors when fetching for plugin information when
opening the plugin manager.

Although the issue lives in the plugin manager repo, the code that
fetches the code still lives in napari, hence with the PR seem to be
better resolved on this side.

# Result

## Before this PR


![napari-before](https://github.com/napari/napari/assets/3627835/6e704463-2dd3-4701-9aa5-93f2501e48fd)


## With this PR


![napari](https://github.com/napari/napari/assets/3627835/ffa3ad0a-da18-4e76-a4aa-8a007f90ce36)

The warning reads: 

>There seems to be an issue with network connectivity. Remote plugins
cannot be installed, only local ones.
goanpeca added a commit to goanpeca/napari-plugin-manager that referenced this issue May 27, 2024
…ng the plugin manager (#6931)

Fixes napari#26

# Description

Catches connectivity errors when fetching for plugin information when
opening the plugin manager.

Although the issue lives in the plugin manager repo, the code that
fetches the code still lives in napari, hence with the PR seem to be
better resolved on this side.

# Result

## Before this PR

![napari-before](https://github.com/napari/napari/assets/3627835/6e704463-2dd3-4701-9aa5-93f2501e48fd)

## With this PR

![napari](https://github.com/napari/napari/assets/3627835/ffa3ad0a-da18-4e76-a4aa-8a007f90ce36)

The warning reads:

>There seems to be an issue with network connectivity. Remote plugins
cannot be installed, only local ones.
goanpeca added a commit to goanpeca/napari-plugin-manager that referenced this issue May 28, 2024
…ng the plugin manager (#6931)

Fixes napari#26

# Description

Catches connectivity errors when fetching for plugin information when
opening the plugin manager.

Although the issue lives in the plugin manager repo, the code that
fetches the code still lives in napari, hence with the PR seem to be
better resolved on this side.

# Result

## Before this PR

![napari-before](https://github.com/napari/napari/assets/3627835/6e704463-2dd3-4701-9aa5-93f2501e48fd)

## With this PR

![napari](https://github.com/napari/napari/assets/3627835/ffa3ad0a-da18-4e76-a4aa-8a007f90ce36)

The warning reads:

>There seems to be an issue with network connectivity. Remote plugins
cannot be installed, only local ones.
andy-sweet pushed a commit to andy-sweet/napari that referenced this issue May 28, 2024
…ng the plugin manager (napari#6931)

Fixes napari/napari-plugin-manager#26

# Description

Catches connectivity errors when fetching for plugin information when
opening the plugin manager.

Although the issue lives in the plugin manager repo, the code that
fetches the code still lives in napari, hence with the PR seem to be
better resolved on this side.

# Result

## Before this PR


![napari-before](https://github.com/napari/napari/assets/3627835/6e704463-2dd3-4701-9aa5-93f2501e48fd)


## With this PR


![napari](https://github.com/napari/napari/assets/3627835/ffa3ad0a-da18-4e76-a4aa-8a007f90ce36)

The warning reads: 

>There seems to be an issue with network connectivity. Remote plugins
cannot be installed, only local ones.
goanpeca added a commit to goanpeca/napari-plugin-manager that referenced this issue Jun 17, 2024
…ng the plugin manager (#6931)

Fixes napari#26

# Description

Catches connectivity errors when fetching for plugin information when
opening the plugin manager.

Although the issue lives in the plugin manager repo, the code that
fetches the code still lives in napari, hence with the PR seem to be
better resolved on this side.

# Result

## Before this PR

![napari-before](https://github.com/napari/napari/assets/3627835/6e704463-2dd3-4701-9aa5-93f2501e48fd)

## With this PR

![napari](https://github.com/napari/napari/assets/3627835/ffa3ad0a-da18-4e76-a4aa-8a007f90ce36)

The warning reads:

>There seems to be an issue with network connectivity. Remote plugins
cannot be installed, only local ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working UX/UI
Projects
None yet
2 participants