Skip to content

Handle python gracefully when npm install has not be done #3337

Closed
@karlcow

Description

@karlcow

starting the project before npm install makes it explode.
Maybe we can handle this in a more graceful way.

(env) ~/code/webcompat.com % flask run
 * Serving Flask app "webcompat:app" (lazy loading)
 * Environment: development
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Writing logs to: /Users/karl/code/webcompat.com/tmp
Statuses Initialization…
Milestones in memory
 * Debugger is active!
 * Debugger PIN: 338-254-341
Writing logs to: /Users/karl/code/webcompat.com/tmp
Statuses Initialization…
Milestones in memory
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/karl/code/webcompat.com/webcompat/templates/__init__.py", line 31, in get_checksum
    checksum = cache_dict[file_path]
KeyError: '/Users/karl/code/webcompat.com/webcompat/static/js/dist/webcompat.min.js'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/karl/code/webcompat.com/env/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/karl/code/webcompat.com/webcompat/views.py", line 167, in index
    push(bust_cache('/js/dist/webcompat.min.js'), **{
  File "/Users/karl/code/webcompat.com/webcompat/templates/__init__.py", line 37, in bust_cache
    return file_path + '?' + get_checksum(STATIC_PATH + file_path)
  File "/Users/karl/code/webcompat.com/webcompat/templates/__init__.py", line 33, in get_checksum
    checksum = md5_checksum(file_path)
  File "/Users/karl/code/webcompat.com/webcompat/templates/__init__.py", line 42, in md5_checksum
    with open(file_path, 'rb') as fh:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/karl/code/webcompat.com/webcompat/static/js/dist/webcompat.min.js'
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
127.0.0.1 - - [10/Jun/2020 12:43:40] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions