forked from PyAr/tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
86 lines (61 loc) · 2.34 KB
/
fabfile.py
File metadata and controls
86 lines (61 loc) · 2.34 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
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
# Fabric script para "deployar" el tutorial de Python 3 en el servidor
# de PyAr y actualizar la version HTML y PDF online en
# http://docs.python.org.ar/tutorial/
from bs4 import BeautifulSoup
from fabric.api import env, local
from traducidos.conf import version
# env.hosts = ['python.org.ar']
# env.shell = '/bin/bash -l -c'
# env.project = '/home/www-pyar/docs.python.org.ar/tutorial/'
env.colorize_errors = True
def do_all():
create_all()
change_htmlindex_version()
deploy_all()
def deploy_all():
deploy_index()
deploy_html3()
deploy_pdf3()
def deploy_index():
local('rsync -rav ' \
'traducidos/web/* ' \
'www-pyar@python.org.ar:/home/www-pyar/docs.python.org.ar/tutorial/')
def deploy_html3():
local('rsync -rav ' \
'traducidos/_build/html/* ' \
'www-pyar@python.org.ar:/home/www-pyar/docs.python.org.ar/tutorial/3/')
def deploy_pdf3():
local('rsync -rav ' \
'traducidos/_build/pdf/TutorialPython.pdf ' \
'www-pyar@python.org.ar:/home/www-pyar/docs.python.org.ar/tutorial/pdfs/TutorialPython3.pdf')
def create_all():
create_html()
create_pdf()
def create_html():
local('cd traducidos && make html')
def create_pdf():
local('cd traducidos && make pdf')
# This command makes the pdf smaller and fixes a SyntaxError that
# Firefox reports and does not show it properly. This error does
# not happen with Evince, for example. We are not really sure how
# this command works, but it does in some way
# This command was tested with pdftk 2.01
local('cd traducidos/_build/pdf && '
'pdftk TutorialPython.pdf cat output output.pdf && '
'mv output.pdf TutorialPython.pdf'
)
def change_htmlindex_version():
# get version from config file
index_filename = 'traducidos/web/index.html'
soup = BeautifulSoup(open(index_filename, 'r').read())
print('Version anterior: {0} | Version nueva: {1}'.format(
soup.find('h3').contents[0].strip(),
version,
))
soup.find('h3').contents[0].replace_with(version)
with open(index_filename, 'w') as fh:
html_content = soup.prettify(soup.original_encoding)
fh.write(html_content)
def update_check_script():
local('scp dev/check_python_tutorial.py '
'humitos@mkaufmann.com.ar:~/src/check_python_tutorial.py')