0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/evergreen/spawnhost/extract_artifacts.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
766 B
Python
Raw Normal View History

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())