1
0

Fix sudo command

This commit is contained in:
Athanasios Xygkis 2020-09-21 17:04:34 +02:00
parent 32a406490f
commit d43005ac48

View File

@ -38,8 +38,8 @@ class TC:
cmd2 = 'tc qdisc change dev {} root netem delay {} {} loss {} {} reorder {} {}'.format(self.interface, *self.losses['delay'], *self.losses['loss'], *self.losses['reordering']) cmd2 = 'tc qdisc change dev {} root netem delay {} {} loss {} {} reorder {} {}'.format(self.interface, *self.losses['delay'], *self.losses['loss'], *self.losses['reordering'])
if self.needSudo: if self.needSudo:
os.system('echo %s | sudo -S {}'.format(cmd1)) os.system("echo {} | sudo -S {}".format(self.sudoPassword, cmd1))
os.system('echo %s | sudo -S {}'.format(cmd2)) os.system("echo {} | sudo -S {}".format(self.sudoPassword, cmd2))
else: else:
os.system(cmd1) os.system(cmd1)
os.system(cmd2) os.system(cmd2)
@ -62,7 +62,7 @@ class TC:
def cleanup(self): def cleanup(self):
cmd = 'tc qdisc del dev {} root 2>/dev/null'.format(self.interface) cmd = 'tc qdisc del dev {} root 2>/dev/null'.format(self.interface)
if self.needSudo: if self.needSudo:
os.system('echo %s | sudo -S {}'.format(cmd)) os.system("echo '{}' | sudo -S {}".format(self.sudoPassword, cmd))
else: else:
os.system(cmd) os.system(cmd)