10.020 DDW

Debug Notes

This notes compile all sorts of bugs that you might encounter when running the mini project. Hopefully this helps 🩹.

TLDR: Running on Vocareum

We have given the steps to you in the README file, we have also written additional explanations for you. But as the cherry on top, here’s the steps:

We assume you follow the easy step, which is to clone the original repository and just paste your answer.

  1. Clone the repository
    git clone https://github.com/Data-Driven-World/d2w_mini_projects.git
    
  2. Refresh the webpage, you should see it in vocareum’s file tree on the left hand side pane
  3. Change directory, install pipenv, install modules, start pipenv shell
    cd d2w_min_projects/mp_sort
    pip install --user pipenv
    pipenv install
    pipenv shell
    
  4. Change the content of /app/__init.py__: set voc=True. You can click the python file from the Vocareum left pane.
    # set voc=False if you run on local computer
    application.wsgi_app = PrefixMiddleware(application.wsgi_app, voc=True)
    
  5. Paste your answer in the relevant files, e.g library.py, *.html files, etc.
  6. Run transcrypt (assuming your current directory is mp_*)
    cd /app/static
    python -m transcrypt -b -n library
    
  7. Go back to mp_* directory, change the bash script to be executable and run:
    cd ../..
    chmod a+x ./runflaskvoc.sh
    ./runflaskvoc.sh
    
  8. Once it is running, you can open another tab in your browser and type the following url: https://myserver.vocareum.com/

Env does not have the var VOC_PROXY_ID

You need to add the trailing slash at the URL as shown in the screenshot below:

bash: ./runflaskvoc.sh /bin/bash^M: bad interpreter

This is due to the way newline is encoded in Windows vs UNIX machines. You can read more about it here.

Fix

  • Open runflaskvoc.sh on vocareum
  • Go to line 2 (the empty line after #!/bin/bash)
  • Press backspace
  • Press enter
  • Wait for it to save
  • Run ./runflaskvoc.sh again

Courtesy of TA Daniel

Error: The server responded with a non-Javascript MIME type of “text/plain”

It means that something might have changed your Windows registry file.

Fix:

  • Open your search bar by pressing Win + R
  • Type in regedit and press enter
  • Find .js under the parent path HKEY_CLASSES_ROOT
  • Change the data field of Content Type from text/plain to application/javascript
  • Save, and then re-run flask run

Courtesy of TA Alex

IndexError: list index out of range

If the error as such appear after typing the transcrypt command:

Traceback (most recent call last):
  File "/mnt/vocwork2/ddd_v1_w_2bG_1401946/asn1029778_3/asn1029779_1/work/.local/share/virtualenvs/mp_sort-K9CB8Yy2/lib/python3.8/site-packages/transcrypt/__main__.py", line 162, in main
    compiler.Program (transpilationDirs, __symbols__, __envir__)
  File "/mnt/vocwork2/ddd_v1_w_2bG_1401946/asn1029778_3/asn1029779_1/work/.local/share/virtualenvs/mp_sort-K9CB8Yy2/lib/python3.8/site-packages/transcrypt/modules/org/transcrypt/compiler.py", line 112, in __init__
    message = f'\n\t{exception}'
  File "/mnt/vocwork2/ddd_v1_w_2bG_1401946/asn1029778_3/asn1029779_1/work/.local/share/virtualenvs/mp_sort-K9CB8Yy2/lib/python3.8/site-packages/transcrypt/modules/org/transcrypt/utils.py", line 215, in __str__
    result += '\n\tFile \'{}\', line {}, namely:'.format (str (program.importStack [-1][0] .name), self.lineNr)
IndexError: list index out of range

then it is likely that you did not execute transcrypt in app/static directory. Simply cd there and re-run the transcrypt command again.