forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chang She
committed
May 15, 2012
1 parent
3987e06
commit bb580cb
Showing
2 changed files
with
89 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'): | ||
|
@@ -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, | ||
|
@@ -112,6 +179,7 @@ def all(): | |
'clean' : clean, | ||
'sf' : sf, | ||
'sfpdf' : sfpdf, | ||
'auto_dev' : auto_dev_build, | ||
'all' : all, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters