-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
139 lines (113 loc) · 2.71 KB
/
tasks.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import functools
import os
from invoke import task
# from fabric.api import env, lcd, local, task
# Local path configuration (can be absolute or relative to fabfile)
env = {
"input_path": "content",
"deploy_path": "output",
"extra_path": "content/_extra",
}
@task
def build(c):
c.run("pelican {input_path} -o {deploy_path} -s pelicanconf.py".format(**env))
# c.run('pelican {input_path} -v -o {deploy_path} -s pelicanconf.py'.format(**env))
def serve(c):
# c.run('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
c.run("cd {deploy_path} && python3 -m http.server".format(**env))
@task
def reserve(c):
build(c)
serve(c)
def gh_pages(c):
c.run(
"cd {deploy_path} && "
"pwd && "
"git st && "
"git add --all . && "
'git ci -am "re-build from local by markdoc @MBP111216ZQ" && '
# 'git pu cafe gitcafe-page '
"git pu && "
"date ".format(**env)
)
@task
def ads(c):
"""cp ads.txt for deloy"""
c.run(
"ls {extra_path} && "
"cp -vf {extra_path}/ads.txt {deploy_path}/ads.txt && "
"date ".format(**env)
)
@task
def pub(c):
pull_data(c)
build(c)
# CNAME()
ads(c)
gh_pages(c)
def pull_data(c):
c.run("cd {deploy_path} && " "pwd && " "git pull".format(**env))
"""
env.deploy_7niu = '7niu'
env.qiniu_bin = '/opt/bin/7niu_package_darwin_amd64/qrsync'
env.qiniu_conf = '../7niu4pychina.json'
def cd_app_root(func):
app_root = os.path.dirname(os.path.realpath(__file__))
@functools.wraps(func)
def _to_app_root(*args, **kwargs):
with lcd(app_root):
return func(*args, **kwargs)
return _to_app_root
@task
@cd_app_root
def pub7niu():
build7niu()
local('pwd && '
'{qiniu_bin} {qiniu_conf} && '
'date '.format(**env)
)
@task
@cd_app_root
def build7niu():
local(
'pelican {input_path} -o {deploy_7niu} -s pelicanconf.py'.format(**env)
)
@task
@cd_app_root
def pub2cafe():
build4cafe()
local(
'cd {deploy_pages} && '
'pwd && '
# 'git pu && '
'git add --all . && '
# 'git st && '
'git ci -am "upgraded in local. @MBP111216ZQ" && '
# 'git pu cafe gitcafe-page '
'git pu && '
'pwd '.format(**env)
)
@task
@cd_app_root
def build4cafe():
local(
'pelican {input_path} -o {deploy_pages} -s pelicanconf.py'.format(**env)
)
@task
@cd_app_root
def serve():
local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
@task
@cd_app_root
def reserve():
build()
serve()
@task
def install_deps():
local(
'pip install '
'beautifulsoup4 '
'Markdown '
'pelican'
)
"""