def makeCommand(self, user, host, filepath, filteruser, sudo=None):
if sudo is None:
["cat", "{filepath}".format(filepath=filepath)]
elif sudo.lower() == 'yes':
command = ["sudo", "cat","{filepath}".format(filepath=filepath)]
elif sudo.lower() == 'no':
command = ["cat", "{filepath}".format(filepath=filepath)]
else:
raise Exception("Please set sudo to either yes/no")
the condition to check 'yes' and 'no' are working well. When the sudo value comes empty I am setting it None as default. The default value is being passed as desired to check if the None condition is working or not I added a print statement and verified but the else part is also running and throwing an exceptions. Why is it so ?
Why is the else part exception running when None is detected
Aucun commentaire:
Enregistrer un commentaire