-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfabfile.py
More file actions
48 lines (40 loc) · 1.15 KB
/
fabfile.py
File metadata and controls
48 lines (40 loc) · 1.15 KB
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
47
#fabfile to generate and publish a Pelican blog as a user page to GitHub
#Mitchell Stanton-Cook 2013
#m.stantoncook@gmail.com
import os
from fabric.api import task
def get_fab_script_location():
"""
Return directory containing fabfile which corresponds to Pelican local base
"""
return os.path.dirname(os.path.realpath(__file__))
def parse_config():
"""
Very simple parser to get the remote repo info
"""
with open(os.path.join(get_fab_script_location(), "config.dat")) as fin:
lines = fin.readlines()
return lines[0].split('=')[-1].strip()
@task
def generate():
"""
Execute the Pelican Makefile
"""
loc = get_fab_script_location()
os.chdir(loc)
os.system("python get_publications.py")
os.system("mkdir output")
os.system("make html")
os.system("cp CNAME output")
return loc
@task
def publish():
"""
Publish the site/blog to GitHub
"""
loc = generate()
uname = parse_config()
os.chdir(loc)
os.system("ghp-import output")
os.system("git push git@github.com:username/username.github.io.git gh-pages:master".replace("username", uname))
return loc