From 3151881de323a7a596990d5f4b79a6e1cf77dc0a Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 30 Jul 2015 17:25:21 -0600 Subject: [PATCH] Keep local copy of repos for statistics work Keeps me from having to mess with all my working areas all the time --- .gitignore | 1 + bin/populate-repos | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 bin/populate-repos diff --git a/.gitignore b/.gitignore index ae8ecdf..eb92ca2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc *.egg-info git_stats +repos diff --git a/bin/populate-repos b/bin/populate-repos new file mode 100755 index 0000000..77958cb --- /dev/null +++ b/bin/populate-repos @@ -0,0 +1,47 @@ +#!/usr/bin/env python +import os +import subprocess +import teamanalysis.repos + +def _clone_repo(target, source): + if os.path.exists(target): + print("Skipping checkout of {}".format(target)) + return + command = [ + 'git', + 'clone', + source, + target, + ] + return subprocess.check_output(command) + +def _create_virtualenv(target): + if os.path.exists(os.path.join(target, 've')): + print("Skipping virtualenv for {}".format(target)) + return + + os.chdir(target) + command = ['virtualenv', '-p', 'python3', 've'] + subprocess.check_output(command) + print("Created virtualenv for {}".format(target)) + +def _install_dependencies(target): + os.chdir(target) + pip = os.path.join(target, 've', 'bin', 'pip') + command = [pip, 'install', '-e', '.[develop]'] + subprocess.check_output(command) + +def main(): + target_root = '/Users/eliribble/src/teamanalysis/repos/' + for repo in teamanalysis.repos.REPOSITORIES: + target = os.path.join(target_root, repo) + source = 'git@bitbucket.org:Authentise/{}.git'.format(repo) + output = _clone_repo(target, source) + _create_virtualenv(target) + try: + _install_dependencies(target) + except subprocess.CalledProcessError as e: + print("Failed to install dependencies for {}: {}".format(target, e)) + +if __name__ == '__main__': + main()