Last active
May 4, 2022 11:40
-
-
Save khancyr/5c53a527280f99b4313cd10ed2a202f3 to your computer and use it in GitHub Desktop.
create500logs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pathlib import Path | |
from shutil import move | |
import random | |
import time | |
# ArduPilot SITL Logs path | |
LOGSPATH = Path("logs") | |
if LOGSPATH.exists() and any(LOGSPATH.iterdir()): | |
print("Backing up current log directory") | |
for i in range(0, 500): | |
backupdir = Path(LOGSPATH.name + str(i)) | |
if not backupdir.exists(): | |
move(str(LOGSPATH.absolute()), backupdir.absolute()) | |
break | |
LOGSPATH.mkdir() | |
print("Add LASTLOG.TXT file with counter at 11") | |
with open("logs/LASTLOG.TXT", 'w') as lastlogfile: | |
lastlogfile.write("11\n") | |
print("Create fakelogs from 11 to 500 on logs directory") | |
for i in range(11, 501): | |
new_log = LOGSPATH / Path(f"{str(i).zfill(8)}.BIN") | |
with open(new_log, 'w+') as logfile: | |
logfile.write(f"I AM LOG {i}\n") | |
for j in range(1, random.randint(0, 5000)): | |
logfile.write("FAKELOG") | |
time.sleep(0.05) | |
print("Wait 5 seconds to have significant different creation time") | |
time.sleep(5) | |
print("Create fakelogs from 1 to 11") | |
for i in range(1, 11): | |
new_log = LOGSPATH / Path(f"{str(i).zfill(8)}.BIN") | |
with open(new_log, 'w+') as logfile: | |
logfile.write(f"I AM LOG {i}\n") | |
for j in range(1, random.randint(0, 5000)): | |
logfile.write("FAKELOG") | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment