def removeScript(filename): try: scripts = getDict(filename) except: printLogo("logo.txt") print("\n\n\t\t\tError: There are no scripts to remove") getch() return None options = list(scripts.keys()) options.append("GO BACK") instructions = "\t What should I remove?" menu = Menu(options, instructions, "logo.txt") temp = menu.prompt() if (temp != len(options) - 1): del scripts[options[temp]] update(filename, scripts)
def openSite(): try: sites = getDict("sites.yaml") except: printLogo("logo.txt") print("\n\t\t\t\tError: There were no sites found.") getch() return None options = list(sites.keys()) options.append("GO BACK") instructions = "\t\t What should I open?" menu = Menu(options, instructions, "logo.txt") temp = 0 while (temp != len(options) - 1): temp = menu.prompt() if (temp != len(options) - 1): webbrowser.open_new_tab("https://" + sites[options[temp]])
def runScript(): try: scripts = getDict("scripts.yml") except: printLogo("logo.txt") print("\n\n\t\t\t\tError: There were no executables found") getch() return None options = list(scripts.keys()) options.append("GO BACK") instructions = "\t Select the executable you want to run" menu = Menu(options, instructions, "logo.txt") temp = 0 while (temp != len(options) - 1): temp = menu.prompt() if (temp != len(options) - 1): run(scripts[options[temp]])
def addExistingStartSite(): try: sites = getDict("sites.yaml") except: printLogo("logo.txt") print("\n\n\t\t\t\tError: No websites were found") getch() return None options = list(sites.keys()) options.append("GO BACK") instructions = "\n\t\t\t\tWhat website should I add?" menu = Menu(options, instructions, "logo.txt") temp = menu.prompt() if (temp != len(options) - 1): try: startupSites = getDict("sitesOnStartUp.yaml") except: startupSites = {} finally: startupSites[options[temp]] = sites[options[temp]] update("sitesOnStartUp.yaml", startupSites)
def addExistingStartupScript(): try: existing_scripts = getDict("scripts.yml") except: printLogo("logo.txt") print("\n\n\t\t\t\tError: No scripts were found") getch() return None options = list(existing_scripts.keys()) options.append("GO BACK") instructions = "\tWhat executable should I add?" menu = Menu(options, instructions, "logo.txt") temp = menu.prompt() if (temp != len(options) - 1): try: scripts = getDict("startupScripts.yml") except: scripts = {} finally: scripts[options[temp]] = existing_scripts[options[temp]] update("startupScripts.yml", scripts)
#!/usr/bin/python3 import os import webbrowser from clmenu import getch, Menu, printLogo import yaml import argparse import subprocess as sub getch = getch() def getDict(filename): with open(filename, "r") as file: data = yaml.load(file) return data def addSite(): try: sites = getDict("sites.yaml") except: #file not found, create new dict sites = {} printLogo("logo.txt") name = input("\n\n\t\t\tName of website: ") url = input("\n\n\t\t\tAddress of website: ") sites[name] = url update("sites.yaml", sites)