5
ALL_REPOS_FILE = 'all_repos.txt'
6
CHARM_PREFIX = "./charms/"
9
def clone_repos(file, branch):
10
with open(file, 'r') as f:
12
print("Doing {} repos".format(len(repos)))
13
# split off the charm name from the repo
15
charm_name = repo.split('/')[-1].split('.')[0]
16
print("Doing {} download".format(charm_name))
17
if charm_name.startswith("charm_"):
18
charm_name = charm_name[6:]
19
charm_dir = CHARM_PREFIX + charm_name
20
if os.path.exists(charm_dir):
21
cmd = "rm -rf {}".format(charm_dir)
22
subprocess.check_call(cmd.split(' '))
23
cmd = "git clone {} {}".format(repo.rstrip('\n'), charm_dir)
24
subprocess.check_call(cmd.split(' '))
25
cmd = "cd {} && git checkout {}".format(charm_dir, branch)
27
subprocess.check_call(cmd.split(' '), shell=True)
32
print("usage: get-charms <master || stable/nn.nn>")
35
clone_repos(ALL_REPOS_FILE, branch)
38
if __name__ == '__main__':