Python Interactive Command Line Menu

Saurav Rana
5 min readNov 8, 2020

--

Hi there ! Today we are going to see a Command Line based interactive menu created by me and my team as part of Team Task under ARTH Initiative.So let’s get started.

First let’s look at our github repository

Before we deep dive into technical stuff there are somethings you need to know.

This menu has been made mainly for linux especially for RHEL8 while we will try to update the code and make it cross-platform

So now lets understand what are all the programs and what they do.To begin with we have readme.md

Raw readme.md

There is a Get Started which will tell us prerequisite steps that we need to do to get running.

  • First, we need to have python 3.8.2 up and running on the machine.RHEL 8 usually comes with python3.6 version so some functions like capture_ouput in subprocess.run() might not work as they were added after 3.6.Thus we need to install python 3.8.2.So go through the readme and install it
  • Also we need to install some additional dependencies which are necessary to run the program.These dependencies have been listed in requirements.txt file and installation instructions along with it.
  • Now that all prerequisites have been taken care of we can show how main program works.

We have multiple folders in the repository , each folder provides a specific service and all related files to that services are in that folder.

We have main.py which is that main file that a user need to run to start the program.

Now we can choose which services we want to use and control it by pressing appropriate keys from keyboard.

Let me show you some demo by running some services.

When we enter 1 we get redirected to AWS page and first it automatically checks for authentication.

If you are not authenticated you are asked to login using your credentials.Then after login we get interface like this.

Now again we can choose and now we choose 3.Then we get

Now lets choose 2.We get

Now here it asks weather we want to update bucket policy if s3 is the origin.We type y for yes

Now we can check in AWS that all the tasks have been done.

Cloudfront Distribution Created
Bucket Policy Updated

Now lets try Partitions i.e. option 2

First we list all partitions i.e. option 3 and we get

It lists all devices and its partitions just under it as you can see /dev/sda and its partitions ( /dev/sda1 , /dev/sda2) below it.

Now we will create partition using option 1

As you can see first it lists partition that device has , if that disk doesn’t have a partition then it will say No Partition Found and will proceed to create new partition.At last we can see partition has been created successfully.

Again we list partitions and now /dev/sdb1 is there

Now we create one more partition again in same disk /dev/sdb and you can see this time it has one partition and new partition has been created of 2 Gib.

Now lets try delete partition

Here you can see partition has been deleted.

Also if we try to delete partition from /dev/sdd which has no partition then it will detect that and return back automatically

Similary, we have option 3 LVM with different options.

So that’s it for the DEMO of our program.Now you can explore the program on your own.

Enjoy…!!!

--

--

Saurav Rana
Saurav Rana

Written by Saurav Rana

When you want to know how things really work, study them when they’re coming apart.

No responses yet