~nskaggs/help-app/pelican-case

7 by Daniel Holbach
add script to create click packages
1
#!/usr/bin/python3
2
3
import glob
4
import os
5
import shutil
6
import subprocess
7
import sys
8
9
10
def project_path():
11
    return os.path.dirname(os.path.abspath(__file__))
12
13
14
def run_hyde():
15
    if not os.path.exists('/usr/bin/hyde'):
16
        print("Please install the package called 'hyde'.")
17
        sys.exit(1)
18
    pwd = os.getcwd()
19
    os.chdir(os.path.join(project_path(), 'edit-here'))
20
    if subprocess.call(['hyde', 'gen']):
21
        print("Running 'hyde' failed.")
22
        sys.exit(1)
23
    os.chdir(pwd)
24
25
26
def create_click():
27
    os.chdir(os.path.join(project_path(), 'app'))
28
    if os.path.exists('www'):
29
        shutil.rmtree('www')
30
    shutil.copytree('../edit-here/deploy/', 'www/')
31
    if subprocess.call(['click', 'build', '.']):
32
        print("Creating click package failed.")
33
        sys.exit(1)
34
    shutil.move(glob.glob('*.click')[0], '..')
35
36
37
def main():
38
    run_hyde()
39
    create_click()
40
41
if __name__ == '__main__':
42
    try:
43
        main()
44
    except KeyboardInterrupt:
45
        print >> sys.stderr, "Aborted."
46
        sys.exit(1)