-
Notifications
You must be signed in to change notification settings - Fork 11
/
tasks.py
162 lines (133 loc) · 3.31 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
__version__ = 'v.210526.1158'
__author__ = 'Zoom.Quiet'
__license__ = 'MIT@2021-05'
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'}
SROOT = os.path.dirname(os.path.abspath(__file__))
print(SROOT)
@task
def ver(c):
'''echo crt. verions'''
print('\n ~> powded by {} <~'.format(__version__))
# support stuff func.
def cd(c, path2, echo=True):
os.chdir(path2)
if echo:
print('\n\t crt. PATH ===')
c.run('pwd')
c.run('echo \n')
@task
def build(c):
print("\t>>> base Pelican build-out html")
# c.run('pelican {input_path} -o {deploy_path} -s pelicanconf.py --debug'.format(**env))
c.run('pelican {input_path} -o {deploy_path} -s pelicanconf.py '.format(**env))
def serve(c):
c.run('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
@task
def reserve(c):
build(c)
serve(c)
def gh_up(c):
print("\t>>> git pu all .md update")
c.run(
'pwd && '
'git st && '
'git add --all . && '
'git ci -am "push all new words for markdoc build" && '
# 'git pu cafe gitcafe-page '
'git pu && '
'date '.format(**env)
)
def gh_pages(c):
print("\t>>> jump-into gh-pages to publish results")
# print(env['deploy_path'])
cd(c, env['deploy_path'])
c.run(
'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)
)
cd(c, SROOT)
def pull_data(c):
# cd(c, env['deploy_path'])
print("\t>>> git pull all others doc.")
c.run('git pull'.format(**env))
cd(c, SROOT)
@task
def pub(c):
pull_data(c)
build(c)
gh_up(c)
# CNAME()
gh_pages(c)
'''
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'
)
'''