def execute(helix, argv): if len(argv) <= 1: print("Usage:\n\tload [option][modname]\nOption:\n" "\t-r || --reload\tReload module.\n" "\t-l || --list\tList all module.\n" "See man load for more details!") return 0 base = ArgsX.Base(len(argv), argv, 1) lopt = [ArgsX.LongOpt("reload", ArgsX.Options["req_arg"], "r"), ArgsX.LongOpt("list", ArgsX.Options["no_args"], "l")] while True: ret = ArgsX.argsx(base, "r+l", lopt, "-") if ret == ArgsX.Status["finish"]: break if ret == "r": pinfo("Reload " + argv[base.argptr] + "...") try: helix.Modules.reload(pypath(path_modules())+argv[base.argptr]) except KeyError as e: perror(str(e) + " not present!") except ImportError: perror("The module " + argv[base.argptr] + " is no longer available!") break elif ret == "l": pinfo("Loading module list...") mdb = MDBmanager() inst = mdb.get_installed_modules() if not inst: perror("No module installed.", "\n") else: print("\nName:\n") for mod in inst: print("[Module]: " + mod) print() break elif ret == ArgsX.Status["lowarg"]: print("Options: " + argv[base.aptr - 1] + " required an argument") break elif ret == ArgsX.Status["badargs"]: perror("Bad Option!") break elif ret == ArgsX.Status["otherdata"]: try: helix.Modules.load(pypath(path_modules())+argv[base.aptr]) except ImportError: perror("The module " + argv[base.argptr] + " was not found!") except OsNotSupported as e: perror(str(e)) break base.aptr += 1 return 0
def execute(helix, argv): if len(argv) <= 1: print("Usage:\n\tunload [-a||--all] || [modname]\n" "Options:\n" "\t-a || --all\tUnload all module.\n" "See man unload for more details!") return 0 base = ArgsX.Base(len(argv), argv, 1) lopt = [ArgsX.LongOpt("all", ArgsX.Options["no_args"], "a")] while True: ret = ArgsX.argsx(base, "a", lopt, "-") if ret == ArgsX.Status["finish"]: break if ret == "a": helix.Modules.unloadall() break elif ret == ArgsX.Status["badargs"]: perror("Bad Option!") break elif ret == ArgsX.Status["otherdata"]: try: helix.Modules.unload(pypath(path_modules())+argv[1]) except KeyError: perror(argv[1] + " not present!") break base.aptr += 1 return 0
def execute(helix, argv): if len(argv) <= 1: print("Usage:\n\tsw [-l||--list] || [modname]\n" "Options:\n" "\t-l || --list\tShow the loaded modules." "See man sw for more details!") return 0 base = ArgsX.Base(len(argv), argv, 1) lopt = [ArgsX.LongOpt("list", ArgsX.Options["no_args"], "l")] while True: ret = ArgsX.argsx(base, "l", lopt, "-") if ret == ArgsX.Status["finish"]: break if ret == "l": print("\n[A]\t\tName:") activename = helix.Modules.getactivemodname() activename = activename and activename or str() for name in helix.Modules.getkeys(): if activename == name: print("[X]\t\t" + name) else: print("[-]\t\t" + name) pinfo("Loaded modules: "+str(helix.Modules.getsize()), "\n") print() break elif ret == ArgsX.Status["badargs"]: perror("Bad Option!") break elif ret == ArgsX.Status["otherdata"]: try: helix.Modules.switch(pypath(path_modules())+argv[base.argptr]) except KeyError: perror(argv[base.argptr] + " not present!") break base.aptr += 1 return 0