I am trying to read in the percentage compeation of Bulk Extractor to be used to update a progress bar. When Bulk Extractor is running it produces an update of the strings compleation in console e.g.
14:55:06 Offset 2315MB (0.90%) Done in 2:50:37 at 17:45:43
14:55:11 Offset 2399MB (0.94%) Done in 2:52:46 at 17:47:57
14:55:16 Offset 2483MB (0.97%) Done in 2:55:32 at 17:50:48
14:55:22 Offset 2566MB (1.00%) Done in 3:01:02 at 17:56:24
14:55:27 Offset 2650MB (1.04%) Done in 3:02:49 at 17:58:16
I want to use regular expression to pull the percentage out of the console. I want to achieve this by doing something like this:
#Using Ipconfig as example command
cmd = "ipconfig"
pipe = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
global output
output= pipe.read()
# Prints ipconfig command
print(output)
#RegX to find % and the next 2 characters
x = re.findall("%\d\d", str(output))
print(x)
Sample output from the console
#IPCONFIG
Ip config b'\r\nWindows IP Configuration\r\n\r\n\r\nEthernet adapter Ethernet 5:\r\n\r\n Connection-specific DNS Suffix . : \r\n Link-local IPv6 Address . . . . . : fe80::54a5:f051:24bd:95bf%18\r\n
#RegX
Regx output ['%18', '%25']
How do I create a while loop to do this, I've been trying to do to achieve this by the following pseudo code:
if bulk extractor is running:
Then True:
while True:
Percent = re.findall("%\d\d", str(output))
#update.progressbar but for now lets just print screen
print("current % =", percent)
#Loop Again
else:
break
Heres the command for Bulk Extractor
cmd = os.system("%programdata%\\bulk_extractor64.exe -o test "\\imagefile\"")
In summary, I want to read in the percentage from Bulk Extractor and continuously update a variable to be used to update a progress bar.
Can anyone help me achieve this or is there a better way of doing it?
Aucun commentaire:
Enregistrer un commentaire