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

Favicon Errors #35

Closed
KyleKing opened this issue Feb 24, 2019 · 5 comments

Comments

2 participants
@KyleKing
Copy link
Contributor

commented Feb 24, 2019

Description

pdoc3 throws errors that a favicon.ico file can't be found.

Is it up to the user to provide a favicon? If not, maybe there should be a default favicon.ico included with pdoc3? Or the error could be circumvented like in pdoc where they intentionally return None: mitmproxy/pdoc/master/pdoc/web.py#L91-L93

    def html(self):
        """
        Retrieves and sends the HTML belonging to the path given in
        URL. This method is smart and will look for HTML files already
        generated and account for whether they are stale compared to
        the source code.
        """
        # Deny favico shortcut early.
        if self.path == "/favicon.ico":
            return None
        return pdoc.render.html_module(pdoc.extract.extract_module(self.import_path))

Error Message

(base) 05:20 [PDOC] ¿ pdoc csv --http localhost:8000
Starting pdoc server on localhost:8000
pdoc server ready at http://localhost:8000
127.0.0.1 - - [24/Feb/2019 05:21:01] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Feb/2019 05:21:03] "GET /favicon.ico HTTP/1.1" 302 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50040)
Traceback (most recent call last):
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/kyleking/anaconda3/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/Users/kyleking/anaconda3/lib/python3.7/http/server.py", line 414, in handle_one_request
    method()
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/cli.py", line 175, in do_GET
    out = self.html()
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/cli.py", line 205, in html
    return pdoc.html(self.import_path_from_req_url, http_server=True)
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/__init__.py", line 471, in html
    mod = Module(import_module(module_name), docfilter=docfilter)
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/__init__.py", line 526, in import_module
    raise ValueError('File or module {!r} not found'.format(module))
ValueError: File or module 'favicon.ico' not found
----------------------------------------
127.0.0.1 - - [24/Feb/2019 05:21:07] "GET /csv HTTP/1.1" 302 -
/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/__init__.py:585: UserWarning: Couldn't get/parse source of '<Class 'csv.Error'>'
  warn("Couldn't get/parse source of '{!r}'".format(doc_obj))
127.0.0.1 - - [24/Feb/2019 05:21:07] "GET /csv/ HTTP/1.1" 200 -
127.0.0.1 - - [24/Feb/2019 05:21:07] "GET /favicon.ico HTTP/1.1" 302 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50102)
Traceback (most recent call last):
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/kyleking/anaconda3/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/kyleking/anaconda3/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/Users/kyleking/anaconda3/lib/python3.7/http/server.py", line 414, in handle_one_request
    method()
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/cli.py", line 175, in do_GET
    out = self.html()
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/cli.py", line 205, in html
    return pdoc.html(self.import_path_from_req_url, http_server=True)
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/__init__.py", line 471, in html
    mod = Module(import_module(module_name), docfilter=docfilter)
  File "/Users/kyleking/anaconda3/lib/python3.7/site-packages/pdoc/__init__.py", line 526, in import_module
    raise ValueError('File or module {!r} not found'.format(module))
ValueError: File or module 'favicon.ico' not found

Steps to Reproduce

  1. Run pdoc csv --http localhost:8000

Additional info

  • pdoc version: 0.5.2
  • OS: Mac OS Mojave 10.14.3
  • Python 3.7.2 (Anaconda)
@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2019

Pdoc3 still uses this code.

pdoc/pdoc/cli.py

Lines 193 to 205 in 24a561c

def html(self):
"""
Retrieves and sends the HTML belonging to the path given in
URL. This method is smart and will look for HTML files already
generated and account for whether they are stale compared to
the source code.
"""
# Deny favicon shortcut early.
if self.path == "/favicon.ico":
return None
# TODO: pass extra pdoc.html() params
return pdoc.html(self.import_path_from_req_url, http_server=True)

It's a bug. PR welcome.

@kernc

This comment has been minimized.

Copy link
Contributor

commented Feb 25, 2019

@KyleKing, care to tackle this one as well?

@KyleKing

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2019

Yeah of course! I also may have found another bug that I’ll open an issue for when I’m back from work tonight

KyleKing added a commit to KyleKing/pdoc that referenced this issue Feb 26, 2019

@kernc kernc closed this in 1e0608f Mar 1, 2019

@kernc

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2019

Sorry, I considered 1e0608f a better fix, which further avoids the needless /favicon.ico/ redirect that took place already in do_GET() method. Thanks for the report though!

What's the other issue?

@KyleKing

This comment has been minimized.

Copy link
Contributor Author

commented Mar 1, 2019

Yeah, it is a more efficient fix!

There is a minor issue on Windows with html linking for module files. I need to borrow my girlfriend’s PC this weekend to test it out and I’ll post an issue once I have a clean way to replicate it

@kernc kernc added this to the 0.5.3 milestone Mar 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.