using shlex on the client
This commit is contained in:
1 parent
e1fbb3b33e
commit
fd11784744
2 files changed
+23
-24
No files matched your search
+5
-5
@@ -2,6 +2,7 @@
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import shlex
|
||||
|
||||
PORT = 5056
|
||||
ALL_IPS = [
|
||||
@@ -49,10 +50,9 @@ def grep_all_ips(ips, cmd, if_unit_test):
|
||||
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client_socket.connect((ip, PORT))
|
||||
|
||||
if if_unit_test:
|
||||
full_cmd = cmd + f" ./machine.{i + 1}.test.log"
|
||||
else:
|
||||
full_cmd = cmd + f" ./machine.{i + 1}.log"
|
||||
filename = f"machine.{i + 1}.test.log" if if_unit_test else f"machine.{i + 1}.log"
|
||||
|
||||
full_cmd = shlex.join(cmd + [filename])
|
||||
|
||||
send_message(client_socket, full_cmd)
|
||||
data = receive_message(client_socket)
|
||||
@@ -74,7 +74,7 @@ def grep_all_ips(ips, cmd, if_unit_test):
|
||||
|
||||
#main
|
||||
#if unit test flag exists, then use the test log files instead of the actual log files
|
||||
cmd = "grep " + " ".join([arg for arg in sys.argv[1:] if arg != "-t"])
|
||||
cmd = ["grep ", *[arg for arg in sys.argv[1:] if arg != "-t"]]
|
||||
#track time
|
||||
start_time = time.perf_counter()
|
||||
match_count = grep_all_ips(ALL_IPS, cmd, if_unit_test=[x for x in sys.argv].count("-t") > 0)
|
||||
|
||||
Reference in new issue
Block a user