A menu driven program in python that I am running on rhel 9
4 min readAug 10, 2023
import cv2
import os
from typing import Dict
import pywhatkit as pwk
from datetime import datetime
import smtplib, ssl
import requests
import YouTubeMusicAPI
import boto3
from cvzone.HandTrackingModule import HandDetector
import time
import subprocess
print("IM YOUR MENU GUY")
print("--------------------------------------------------------------------------------------------")
ch=input("Enter what you want me to do, I can do almost anything")
ch=ch.lower()
print(ch)
a=(("run" in ch) or ("start" in ch) or ("execute" in ch) or ("turn on" in ch) or("open" in ch))
b=("gedit" in ch)
#print(bool(a)) #can be used for debugging
#print(bool(b)) #can be used for debugging
if (a and b):
#print(bool(a))
#print(bool(b))
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("gedit")
elif (a and ("facebook" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox www.facebook.com")
elif (a and ("browser" in ch)or("firefox" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox ")
em=("email" in ch) or ("gmail" in ch )or ( "mail" in ch)
if (a and em ):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox www.gmail.com")
elif (a and ("whatsapp" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox https://web.whatsapp.com/")
elif (a and ("youtube" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox www.youtube.com")
elif (a and ("reddit" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox www.reddit.com")
elif (a and ("linuxworld" in ch)):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
subprocess.getoutput("firefox https://www.lwindia.com/")
msg=(("message" in ch) or ("text" in ch) or ("ping" in ch) or ("messege" in ch))
wtp=("whatsapp" in ch) and("send" in ch or "forward" in ch)
if (msg and wtp):
if ("dont" in ch or "do not" in ch):
print("okay i wont run the app")
else:
time=datetime.now()
timeh=int(time.strftime("%H"))
timem=int(time.strftime("%M"))
uptimem=timem + 1
print("Yes i can send a text through whatsapp")
print("")
# using Exception Handling to avoid unexpected errors
try:
print("Please tell me the messege you want to send ")
messege=input()
number=input("Please tell me the number you want me to send a text to")
pwk.sendwhatmsg("+91"+number, messege,timeh,uptimem)
print("Message Sent!") #Prints success message in console
except:
print("Error in sending the message")
music=("play" in ch) or ("stream" in ch) or ("hear" in ch)
song=("music" in ch) or("song" in ch) or ("ganna" in ch)
vid=("video" in ch)or("videos" in ch)or("vedios" in ch) or("vid" in ch)
if(music and vid):
if (("dont" in ch) or ("do not" in ch)):
print("okay i wont run the app")
else:
print("I will play the video")
print("")
vidnme = input("Give me what you want to search please")
#print(vidnme)
vidnme2=vidnme.replace(" ","+")
#print(vidnme2)a
if vidnme2:
print("https://www.youtube.com/results?search_query="+vidnme2)
subprocess.getoutput("firefox https://www.youtube.com/results?search_query="+vidnme2)
else:
print("No Result Found")
fm=("mail" in ch) or ("email" in ch)
snd=("send"in ch) or ("email them" in ch) or ("forward" in ch)
if(fm and snd):
print("to prevent any errors we'll require you to type the email address by hand")
print("")
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = "minlinuxoth@gmail.com" # Enter your address
receiver_email = input("please enter the email address") # Enter receiver address
password = "eyhmddaiyhcxxyny"
messegemail=input("Please tell me the messege you want to send ")
messagemail=messegemail
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, messagemail)
cam=("camera" in ch) or ("photo" in ch) or ("picture" in ch) or ("pic" in ch)
openit=("open" in ch) or ("take" in ch) or ("click" in ch) or ("capture" in ch)
if(cam and openit):
if (("dont" in ch) or ("do not" in ch)):
print("okay i wont")
else:
subprocess.getoutput("guvcview")
ec=("ec2" in ch) or ("aws" in ch) or ("amazon linux" in ch)or("linux" in ch)
insta=("launch" in ch) or ("open" in ch) or ("make" in ch) or ("initiate" in ch ) or ("instance" in ch)
if(ec and insta):
ec2=boto3.client("ec2")
insta1=int(input("how many instances do you want to open"))
instances = ec2.run_instances(
ImageId="ami-0ded8326293d3201b",
MinCount=insta1,
MaxCount=insta1,
InstanceType="t2.micro")
doc=("docker" in ch)or("centos" in ch) or ("container" in ch)
if(doc and insta):
subprocess.getoutput("systemctl start docker")
imgpull=input("enter the image name you want to pull from internet: ")
subprocess.getoutput("docker pull "+imgpull)
print("The image has been successfully pulled, now you can run an instance of the pulled image by running docker run -it (image name u just pulled)")
subprocess.getoutput replaces os.system, rest is the same and fairly an easy code