-
Notifications
You must be signed in to change notification settings - Fork 1
Making Custom Modules
Ok so all of the modules are basically functions in IfElseFuncs.py, you will need some python knowledge for this
lets look at my ReturnTrue
module
the full code for that module is
requiredinputs = ["type", "commands", "function", "description", "points"]
if(checkenoughinputs(inputs, requiredinputs)):
pass
else:
print("missing/extra input for section " + section)
sys.exit()
Type = config[section]["Type"]
if(Type == "Single"):
if(len(str(config[section]["commands"]).split(",")) > 1 ):
print("more than one command on certain section Exiting....")
sys.exit()
elif(Type == "Multi"):
if(len(str(config[section]["commands"]).split(",")) < 2 ):
print("less thantwo command on certain section Exiting....")
sys.exit()
elif(Type == "OneOrOther"):
if(len(str(config[section]["commands"]).split(",")) < 2 ):
print("less thantwo command on certain section Exiting....")
sys.exit()
else:
print("Unknown type of type, exiting...")
sys.exit()
if(Type == "Single"):
try:
subprocess.check_output(str(config[section]["commands"]).split(",")[0], shell=True)
print("hi")
return True
print("he")
except subprocess.CalledProcessError:
return False
elif(Type == "Multi"):
for command in str(config[section]["commands"]).split(","):
try:
subprocess.check_output(command, shell=True)
except subprocess.CalledProcessError:
return False
return True
elif(Type == "OneOrOther"):
for command in str(config[section]["commands"]).split(","):
try:
subprocess.check_output(command, shell=True)
return True
except subprocess.CalledProcessError:
pass
return False
but we can condense it to its essentials
def ReturnTrue(section, inputs): #return true true if command gives a return of 1 else 0
requiredinputs = ["type", "commands", "function", "description", "points"]
if(checkenoughinputs(inputs, requiredinputs)):
pass
else:
print("missing/extra input for section " + section)
sys.exit()
<insert code here that asses to return true or false>
whenever you put a function in a section, the MainEngine.py dynamically calls that function, it passes all the input values of that section and the section name to the function - so first of all you wanna check if you got all the inputs, just use my function called checkenoughinputs
input a required inpusta array (needs to have description and points input + custom input like in the example), if there are enough inputer, pass and do the function, if there arent exit out and leave a error log.
After this we can do stuffz with the input to make functions like that test if users exists etc