0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-27 23:27:11 +01:00
mongodb/evergreen/spawnhost/extract_artifacts.py
Trevor Guidry 0f59df3e9e SERVER-96279 Make resmoke easier to run on spawnhosts (#28592)
GitOrigin-RevId: 3fb08e4fb138eb0c9155f599777701463597cb02
2024-10-29 17:04:39 +00:00

30 lines
766 B
Python

import glob
import os
import sys
import tarfile
def main():
data_dir = "/data/mci"
artifact_files = glob.glob("artifacts*archive_dist_test/artifacts*.tgz", root_dir=data_dir)
if len(artifact_files) > 1:
raise RuntimeError("More than one artifacts file found")
if len(artifact_files) == 0:
print("No artifacts file found, this was probably not generated from a resmoke task.")
return 0
home_dir = os.environ.get("HOME", None)
if not home_dir:
raise RuntimeError("HOME env var could not be found")
artifact_path = os.path.join(data_dir, artifact_files[0])
with tarfile.open(artifact_path, "r") as tar:
tar.extractall(home_dir)
return 0
if __name__ == "__main__":
sys.exit(main())