Skip to content

Commit

Permalink
DOC: function for auto docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
Chang She committed May 15, 2012
1 parent 3987e06 commit bb580cb
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 24 deletions.
106 changes: 87 additions & 19 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,29 @@

SPHINX_BUILD = 'sphinxbuild'

def sf():
'push a copy to the sf'
os.system('cd build/html; rsync -avz . wesmckinn,[email protected]'
':/home/groups/p/pa/pandas/htdocs/ -essh --cvs-exclude')

def upload_dev():
'push a copy to the pydata dev directory'
os.system('cd build/html; rsync -avz . [email protected]'
':/usr/share/nginx/pandas/pandas-docs/dev/ -essh')
if os.system('cd build/html; rsync -avz . [email protected]'
':/usr/share/nginx/pandas/pandas-docs/dev/ -essh'):
raise SystemExit('Upload to Pydata Dev failed')

def upload_dev_pdf():
'push a copy to the pydata dev directory'
os.system('cd build/latex; scp pandas.pdf [email protected]'
':/usr/share/nginx/pandas/pandas-docs/dev/')
if os.system('cd build/latex; scp pandas.pdf [email protected]'
':/usr/share/nginx/pandas/pandas-docs/dev/'):
raise SystemExit('PDF upload to Pydata Dev failed')

def upload_stable():
'push a copy to the pydata dev directory'
os.system('cd build/html; rsync -avz . [email protected]'
':/usr/share/nginx/pandas/pandas-docs/stable/ -essh')
'push a copy to the pydata stable directory'
if os.system('cd build/html; rsync -avz . [email protected]'
':/usr/share/nginx/pandas/pandas-docs/stable/ -essh'):
raise SystemExit('Upload to stable failed')

def upload_stable_pdf():
'push a copy to the pydata dev directory'
os.system('cd build/latex; scp pandas.pdf [email protected]'
':/usr/share/nginx/pandas/pandas-docs/stable/')

def sfpdf():
'push a copy to the sf site'
os.system('cd build/latex; scp pandas.pdf wesmckinn,[email protected]'
':/home/groups/p/pa/pandas/htdocs/')
if os.system('cd build/latex; scp pandas.pdf [email protected]'
':/usr/share/nginx/pandas/pandas-docs/stable/'):
raise SystemExit('PDF upload to stable failed')

def clean():
if os.path.exists('build'):
Expand Down Expand Up @@ -102,6 +96,79 @@ def all():
# clean()
html()

def auto_dev_build():
msg = ''
try:
clean()
html()
latex()
upload_dev()
upload_dev_pdf()
sendmail()
except (Exception, SystemExit), inst:
msg += str(inst) + '\n'
sendmail(msg)

def sendmail(err_msg=None):
from_name, to_name = _get_config()

if err_msg is None:
msgstr = 'Daily docs build completed successfully'
subject = "DOC: daily build successful"
else:
msgstr = err_msg
subject = "DOC: daily build failed"

import smtplib
from email.MIMEText import MIMEText
msg = MIMEText(msgstr)
msg['Subject'] = subject
msg['From'] = from_name
msg['To'] = to_name

server_str, port, login, pwd = _get_credentials()
server = smtplib.SMTP(server_str, port)
server.ehlo()
server.starttls()
server.ehlo()

server.login(login, pwd)
try:
server.sendmail(from_name, to_name, msg.as_string())
finally:
server.close()

def _get_dir():
import getpass
USERNAME = getpass.getuser()
if sys.platform == 'darwin':
HOME = '/Users/%s' % USERNAME
else:
HOME = '/home/%s' % USERNAME

tmp_dir = '%s/tmp' % HOME
return tmp_dir

def _get_credentials():
tmp_dir = _get_dir()
cred = '%s/credentials' % tmp_dir
with open(cred, 'r') as fh:
server, port, un, domain = fh.read().split(',')
port = int(port)
login = un + '@' + domain + '.com'

import base64
with open('%s/cron_email_pwd' % tmp_dir, 'r') as fh:
pwd = base64.b64decode(fh.read())

return server, port, login, pwd

def _get_config():
tmp_dir = _get_dir()
with open('%s/config' % tmp_dir, 'r') as fh:
from_name, to_name = fh.read().split(',')
return from_name, to_name

funcd = {
'html' : html,
'upload_dev' : upload_dev,
Expand All @@ -112,6 +179,7 @@ def all():
'clean' : clean,
'sf' : sf,
'sfpdf' : sfpdf,
'auto_dev' : auto_dev_build,
'all' : all,
}

Expand Down
7 changes: 2 additions & 5 deletions vb_suite/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ def auto_update():
clean()
html()
upload()
except Exception, inst:
msg += str(inst) + '\n'

if len(msg) == 0:
sendmail()
else:
except (Exception, SystemExit), inst:
msg += str(inst) + '\n'
sendmail(msg)

def sendmail(err_msg=None):
Expand Down

0 comments on commit bb580cb

Please sign in to comment.