Update menu

This commit is contained in:
Dimitris Zlatanidis 2015-07-04 11:54:11 +03:00
parent 109ee25055
commit 056e60f64f

View file

@ -28,36 +28,38 @@ from __metadata__ import MetaData as _meta_
class Auto(object): class Auto(object):
"""Select Slackware command to install packages"""
def __init__(self, packages): def __init__(self, packages):
self.packages = packages self.packages = packages
self.meta = _meta_ self.meta = _meta_
self.commands = { self.commands = {
"1": "installpkg", "i": "installpkg",
"2": "upgradepkg --install-new", "u": "upgradepkg --install-new",
"3": "upgradepkg --reinstall" "r": "upgradepkg --reinstall"
} }
def select(self): def select(self):
print("\nFound Slackware binary package for installation:\n") print("\nDetected Slackware binary package for installation:\n")
for pkg in self.packages: for pkg in self.packages:
print(" " + pkg.split("/")[-1]) print(" " + pkg.split("/")[-1])
print("") print("")
Msg().template(78) Msg().template(78)
print("| Chose a command:") print("| Choose a Slackware command:")
Msg().template(78) Msg().template(78)
for key in sorted(self.commands): for com in sorted(self.commands):
print("| {0}. {1}{2}{3}".format(key, self.meta.color["GREEN"], print("| {0}{1}{2}) {3}{4}{5}".format(
self.commands[key], self.meta.color["RED"], com, self.meta.color["ENDC"],
self.meta.color["ENDC"])) self.meta.color["GREEN"], self.commands[com],
self.meta.color["ENDC"]))
Msg().template(78) Msg().template(78)
self.choice = raw_input(" > ") self.choice = raw_input(" > ")
self.execute() self.execute()
def execute(self): def execute(self):
if self.choice in self.commands.keys(): if self.choice in self.commands.keys():
if self.choice == "1": if self.choice == "i":
PackageManager(self.packages).install("") PackageManager(self.packages).install("")
elif self.choice in ["2", "3"]: elif self.choice in ["u", "r"]:
PackageManager(self.packages).upgrade( PackageManager(self.packages).upgrade(
self.commands[self.choice][11:]) self.commands[self.choice][11:])