Command Line to Cloud GUI w/ WayScript

Jesse Orshan
5 min readFeb 10, 2021

Many times over my years as a backend software developer, I’ve built scripts that automate tasks (primarily with python and shell scripting). Automating excel processing, building web scrapers, etc. were great ‘hacks’ to improve productivity.

Building Command Line Scripts

Usually my scripts would be simple in architecture. Here’s an example of a simple web-scraping tool:

- my_project (root)
---- scraper.py
---- emailer.py
---- results
-------- scrape_01.csv
---- requirements.txt
---- README.md
---- venv

Inside the scraper.py file, I would use Selenium with a headless Chrome browser to run web scraping automations. The scraped data is written to results/scrape_01.csv and generates an email using emailer.py.

Often, I would build these scripts with a simple ‘Command Line Interface’ which allowed me to input custom information into each run.

(scraper.py)from selenium import webdriver
...
name = raw_input("Users First Name: ").strip()
email = raw_input( "Users Email: ").strip()
...

Here is what it looks like running from the CL:

Prompted for inputs
Inputs are entered and then script runs

Turning this script into a “Production Tool”

Ok, so here’s the rub. Working with the cmd line to run my scripts on my local machine was super easy when I was the only one using the tool. But often, other co-workers would learn about the tool and wanted to use it. Suddenly, the command line interface didn’t cut it. Most of these co-workers didn’t even know what a command line was and I couldn’t expect them to set up a python environment, pull the repo from GitHub, etc. In other words, I needed a way to quickly ‘productize’ the script.

The limited, “options” for productizing a script.

Whenever I researched how to do this, there seemed to be 2 options — either build a server or build a native GUI interface. However, both of these routes required so much added work:

1) Build/host a web server with Flask or Django

The first option was building a server which co-workers could access through their browser. However, I have built server applications before and the infra to set this up would end up taking much more time than building the core scraper I wanted to share and would have a bunch of headaches along the way. For example, I’d need to build an interface, set up a server on Heroku, set up deployments, create a db for user access controls, create logged-in/logged-out states, figure out how to get unique instances of Selenium running on Heroku, the list went on and on and on and on…

2) Build/package a native GUI interface using tkinter or pyqt.

The second route was trying to build a native GUI application. However, similar to building a server this would be a time consuming process. GUI building is often a tedious process and comes with its own set of challenges. First, whenever I made a changed or fixed a bug, users would have to redownload updated versions of the application. Also, compiling the application for working on various operating systems is notoriously tedious. Thirdly, running background processes such as selenium has challenges. Finally, this approach just doesn’t feel very ‘modern’ and limits usage to a desktop.

In summary, both of these options required so much added work and had their own limitations. What I want is a way to quickly spin up a productized version of my tool with minimal changes to it’s architecture.

WayScript == Production State in Minutes

The WayScript development engine provides a flexible, rapid way to turn a script into a production grade application. I am able to turn this local script into a production, cloud based tool in 3 steps.

1) Upload Repository / Code

To begin, each program set up on WayScript gives users access to a cloudfile directory where they can upload, read, write, and manipulate an aribtrary folder/file structure (manually or through code).

I am able to drag and drop my project onto WayScript

The neat thing about this virtual file system is that it updates dynamically. Everytime my code runs, it adds a new csv file to the my_project/results/ directory. (A command line client for directly uploading/downloading files through the terminal is coming soon)

2) Setup The User Interface

To do this, I use the pre-built Form Trigger provided by WayScript.

Add The Form Trigger

Next, I create two Text Input fields on my form called Name and Email (The same inputs I was inputting from the Command Line)

I set up 2 text input fields ( Name and Email)

Just like that, I can press the ‘View Form’ button and can see the live endpoint. This endpoint’s styling and logo can be totally customized with CSS if I want. I can also password protect this endpoint by setting up as many login/passwords as I want to distribute to team members.

Live Endpoint Form

3) Pass User Submitted Inputs into my Python Script

The final piece is to get the submitted Form inputs into my script. To do this, I tell WayScript that on Form submission I want to execute python code by setting up a Python module after the form trigger.

I set up my python step

Lastly, in my scraper.py file I update the raw_input functions to get the values directly from WayScript’s variable system.

Notice how I am able to access the Form data through a python variable called variables .

Just like that — my python scripts can now run in the cloud and receive inputs from others! What do you think?

At WayScript, we are building a platform for developers looking to quickly build internal tooling.

--

--