Skip to content
Snippets Groups Projects
update_envsetup.py 767 B
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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)
    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)