#!/usr/bin/env python3 import os import subprocess import sys import utils if __name__ == "__main__": branch = utils.get_conf("ENVSETUP_BRANCH") or "stable" os.chdir(os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))) sys.stdout.write("Updating envsetup: ") sys.stdout.flush() subprocess.call("find . -name *.pyc -type f -delete", shell=True) subprocess.call("find . -name __pycache__ -type d -delete", shell=True) subprocess.check_call(["git", "fetch", "--recurse-submodules", "--all"]) subprocess.check_call(["git", "reset", "--hard", "origin/{}".format(branch)]) if branch: subprocess.check_call(["git", "checkout", branch]) subprocess.check_call(["git", "pull", "--recurse-submodules"]) subprocess.check_call(["git", "submodule", "update", "--init", "--recursive"]) subprocess.call("find . -type d -empty -delete", shell=True)