~ajkavanagh/+junk/useful-things

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
# Sync the charmhelpers accross all the charms that we have
# Note that this only works if there is a charm-helpers-hooks.yaml in the
# directory

import os
import subprocess
import sys

CHARM_PREFIX = "./charms/"


def sync_charms():
    top_level_dirs = sorted(os.walk(CHARM_PREFIX).next()[1])
    for d in top_level_dirs:
        p = os.path.join(".", "charms", d)
        f = os.path.join(p, "charm-helpers-hooks.yaml")
        if os.path.isfile(os.path.join(f)):
            cmd = "make sync".format(p)
            print(cmd)
            subprocess.check_call(cmd.split(" "), cwd=p)


def main(argv):
    sync_charms()


if __name__ == '__main__':
    main(sys.argv)