Skip to content

Commit

Permalink
out: Do not look for files in sandboxed 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 12, 2024
1 parent b35a2d8 commit 120f1b5
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions out
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

# Find this path:
#
# /home/user/.cache/bazel/_bazel_user/7e6ad621f3f951c3ee6f5b179289b54e/sandbox/linux-sandbox/380/execroot/_main/bazel-out/k8-fastbuild/bin/
# /home/user/.cache/bazel/_bazel_user/7e6ad621f3f951c3ee6f5b179289b54e/execroot/_main/bazel-out/k8-fastbuild/bin/
#
# Where:
# _bazel_user is a folder where "user" is the username
# 7e6ad621f3f951c3ee6f5b179289b54e is the most recent folder
# 380 is the most recent folder
#
# Then print out the path

Expand All @@ -30,25 +29,12 @@ def find_path():
for d in dirs:
if not re.match(r'[a-z0-9]{32}', d):
continue

path2 = os.path.join(path, d, "sandbox/linux-sandbox")
path2 = os.path.join(path, d,
"execroot/_main/bazel-out/k8-fastbuild/bin")
if not os.path.exists(path2):
continue

dirs2 = os.listdir(path2)
dirs2.sort(key=lambda x: os.path.getmtime(os.path.join(path2, x)), reverse=True)
dirs2.reverse()

for d2 in dirs2:
if not re.match(r'[0-9]+', d2):
continue

path3 = os.path.join(path2, d2,
"execroot/_main/bazel-out/k8-fastbuild/bin")
if not os.path.exists(path3):
continue

return path3
return path2

print("Could not find path")
sys.exit(1)
Expand All @@ -59,7 +45,8 @@ def recurse(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)):
return recurse(os.path.join(path, f))
if found_file := recurse(os.path.join(path, f)):
return found_file
elif f.endswith(".log"):
return os.path.join(path, f)
return None
Expand Down

0 comments on commit 120f1b5

Please sign in to comment.