summaryrefslogtreecommitdiff
path: root/manage.py
blob: 50249e5ecaf74526c7f195e2c7647970c55e8ce3 (plain)
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
40
41
42
43
44
45
#!/usr/bin/python3


import sys
import subprocess
import json


CONFIG_PATH = "./config.json"


def main():

    if len(sys.argv) != 2:
        print("Provide exactly one parameter")
        sys.exit(1)

    cfg = read_config()

    command = sys.argv[1]
    
    if command == "deploy":
        for deployment in cfg["deployments"]:
            subprocess.call(
                "rsync -av ./webroot/ {0}@{1}:{2}".format(
                    deployment["username"],
                    deployment["host"],
                    deployment["webroot"]
                ), 
                shell=True
            )
    else:
        print("Unknown command")

def read_config():
    with open(CONFIG_PATH, "r") as f:
        content = f.read()
    return json.loads(content)

if __name__ == "__main__":
    main()


# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab