1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import os
import subprocess
import sys
ALL_REPOS_FILE = 'all_repos.txt'
CHARM_PREFIX = "./charms/"
def clone_repos(file, branch):
with open(file, 'r') as f:
repos = f.readlines()
print("Doing {} repos".format(len(repos)))
# split off the charm name from the repo
for repo in repos:
charm_name = repo.split('/')[-1].split('.')[0]
print("Doing {} download".format(charm_name))
if charm_name.startswith("charm_"):
charm_name = charm_name[6:]
charm_dir = CHARM_PREFIX + charm_name
if os.path.exists(charm_dir):
cmd = "rm -rf {}".format(charm_dir)
subprocess.check_call(cmd.split(' '))
cmd = "git clone {} {}".format(repo.rstrip('\n'), charm_dir)
subprocess.check_call(cmd.split(' '))
cmd = "cd {} && git checkout {}".format(charm_dir, branch)
print(cmd)
subprocess.check_call(cmd.split(' '), shell=True)
def main(argv):
if len(argv) < 2:
print("usage: get-charms <master || stable/nn.nn>")
exit(1)
branch = argv[1]
clone_repos(ALL_REPOS_FILE, branch)
if __name__ == '__main__':
main(sys.argv)
|