Harmonizing a Windows-side Python Script with a Linux-side Python Script
I recently completed a project on JupyterLab, LXD, and WSL that required 60K queries and the use of a VPN and Windows desktop client. To make the process easier, I created a Python-side script to check for the existence of a file. Read my blog post to find out how I tackled this complex project!
Tackling a Complex Project: How I Harmonized a Windows-side Python Script with a Linux-side Python Script
By Michael Levin
Saturday, October 1, 2022
I did a project last week that really tested my JupyerLab on LXD on WSL approach. It was a SERP scraping job that had nearly 60K queries in all. Now you can’t do this just off your laptop without VPN, so I used VPN. Problem being that the VPN software has a slick Windows desktop client from which I had to cycle IPs but I couldn’t issue the commands from Linux-side because the Windows automation piece, PyWinAuto, doesn’t run from Linux. It only runs from Python under Windows! Catch-22 and right after I spent all that time getting myself fully on Linux Jupyter!
So I simply made a Python-side script that checked for the existence of a file indicating the IP was still good. Once the file wasn’t there, the VPN software acquired a new IP and the file was put back in place. Whenever the Linux-side script realized the IP was no longer good, it deleted the file. And so I harmonized a Linux-side Python script with a Windows-side Python script and it was far better than doing the whole project under Windows again. I am resisting re-installing Windows-side Jupyter at this point.
An interesting side-note is that I had uninstalled the Python 3.10.5 that I had gotten earlier from Python.org and now I’m installing Python through the Microsoft store to see if it keeps itself auto-upgraded. If not, I can update all from the Microsoft Store and see what happens. As of the time of writing this, it’s Python 3.10.7 from the store.