~nskaggs/help-app/pelican-case

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
46
#!/usr/bin/python3

import glob
import os
import shutil
import subprocess
import sys


def project_path():
    return os.path.dirname(os.path.abspath(__file__))


def run_hyde():
    if not os.path.exists('/usr/bin/hyde'):
        print("Please install the package called 'hyde'.")
        sys.exit(1)
    pwd = os.getcwd()
    os.chdir(os.path.join(project_path(), 'edit-here'))
    if subprocess.call(['hyde', 'gen']):
        print("Running 'hyde' failed.")
        sys.exit(1)
    os.chdir(pwd)


def create_click():
    os.chdir(os.path.join(project_path(), 'app'))
    if os.path.exists('www'):
        shutil.rmtree('www')
    shutil.copytree('../edit-here/deploy/', 'www/')
    if subprocess.call(['click', 'build', '.']):
        print("Creating click package failed.")
        sys.exit(1)
    shutil.move(glob.glob('*.click')[0], '..')


def main():
    run_hyde()
    create_click()

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        print >> sys.stderr, "Aborted."
        sys.exit(1)