Skip to content

Commit

Permalink
out: Look for newest log file across all directories
Browse files Browse the repository at this point in the history
Signed-off-by: Eryk Szpotanski <[email protected]>
  • Loading branch information
eszpotanski committed Apr 22, 2024
1 parent 5469c13 commit b1c8ba0
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions out
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import re
import argparse
import hashlib
from pathlib import Path
from glob import glob

PROJECT_DIR = Path(__file__).parent.resolve()

Expand All @@ -40,17 +41,9 @@ def find_path():
sys.exit(1)


def recurse(path):
files = os.listdir(path)
files.sort(key=lambda x: os.lstat(os.path.join(path, x)).st_mtime, reverse=True)
for f in files:
if os.path.isdir(os.path.join(path, f)):
result = recurse(os.path.join(path, f))
if result is not None:
return result
elif f.endswith(".log"):
return os.path.join(path, f)
return None
def find_newest_log(path):
files = glob(path + "/**/*.log", recursive=True)
return max(files, key=os.path.getmtime, default=None)


if __name__ == "__main__":
Expand All @@ -67,7 +60,7 @@ if __name__ == "__main__":
# .tmp.log:
#
# path + '/logs/asap7/DigitalTop/2_6_floorplan_pdn.tmp.log'
tmpfile = recurse(path + '/logs')
tmpfile = find_newest_log(path + '/logs')
if tmpfile is None:
print("Could not find tmp file")
sys.exit(1)
Expand Down

0 comments on commit b1c8ba0

Please sign in to comment.