Skip to content

Instantly share code, notes, and snippets.

@jonasstein
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonasstein/9bb9cdd292edde787f02 to your computer and use it in GitHub Desktop.
Save jonasstein/9bb9cdd292edde787f02 to your computer and use it in GitHub Desktop.
gentoo menu in python (qe) quickemerge script
#!/usr/bin/env python3
import subprocess
# save the script to /usr/local/bin/qe.py
def my_cmd(thecommand):
return_code = subprocess.call(thecommand, shell=True)
def my_quit_fn():
raise SystemExit
def invalid():
print("Wrong key. Please try again.")
menu = {"1":("sync package list: ","eix-sync"),
"2":("clean: ","emerge --depclean && eclean distfiles"),
"3":("update:","emerge --update --newuse --keep-going @world"),
"4":("show logs:","elogv"),
"5":("read news:","eselect news read new"),
"q":("Quit ","echo bye!")
}
for key in sorted(menu.keys()):
print(key+": " + menu[key][0] + menu[key][1])
ans = input("please select: ")
my_cmd(menu.get(ans,[None,invalid])[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment