Debug Python with VsCode


Visual Studio Code debugs Python. Here are the steps on Windows 10.
Create a folder with a .py file in it, e.g. Rio\proj\python\caller.py
Run code.exe, open the folder Rio\proj\python
Install extension: ms-python.python, which is the Python extension for VsCode from Microsoft.
Install pathon:
https://www.python.org/downloads python-3.7.3.exe 32bit 24M
which installs to C:\Users\rio\AppData\Local\Programs\Python\Python37-32\python.exe
Add config: click Debug then Add config, which creates S:\Rio\proj\python\.vscode\launch.json
Choose interpreter:
From Command Palette, type: Python: Select Interpreter
The installed python should be listed there, and click it.
Debug: open caller.py, set break point, hit the debug icon, they hit the green arrow in the tool bar.
execution should stop and variables can be inspected by mouse over.VsCodePy

Advertisements

Google Plus takeout to static html


Google Plus shutdown earlier April 2019, and I downloaded by Google takeout tools.
Each post becomes a static html page in the takeout, which needs conversion.
I wrote a python tool to convert one year of posts into a single page. Totally hundreds of posts from the last 6 years.
A “Read More” button was added so that it shows a few posts initially, and show all when button clicked.
It was done by Python and Javascript with no framework.
I tried ghost, the publishing platform based on Node.js, but felt it was a overkill.

Tools used:

Ghost: Ghost v2.14.1, requires Node.js version 10. default port 2368 and bind only to locahost in config.development.json.
expose to internet by nginx proxy in proxy_pass https://127.0.0.1:2368;
Python to parse Google Plus Takeout files, modules used by main.py:
html.parser, html.entities, ntpath since it’s on Windows 10, re to extract Youtube ID.
The JavaScript Read More button:
reorder the posts in reverse chronological order by document.body.childNodes
hide the earlier posts by putting them into a <span> and swap between .style.display = “none” .style.display = “inline”

Here is a sample page converted from google takeout, most postings in Chinese:
http://riowing.net/post/2019.htm

Python at MaxxSports


C++ has been my primary language in my entire career until a year ago, when Python came to our tool set.
We chose Python for it’s rich collection of modules. In our case, for example:

  1. AI: keras module to TensorFlow for player recognition
  2. REST API: bottle and json module, through which AWS server talks to the clients
  3. Database: pymysql module access video recordings saved in MySql
  4. HLS Playlist parsing: m3u8 module
  5. Access AWS: boto3 module to control ec2 instances