Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Python Data Science Handbook
Project: Python Data Science Handbook
Views: 94669from fabric.api import *1import fabric.contrib.project as project2import os3import shutil4import sys5import SocketServer67from pelican.server import ComplexHTTPRequestHandler89# Local path configuration (can be absolute or relative to fabfile)10env.deploy_path = 'output'11DEPLOY_PATH = env.deploy_path1213# Remote server configuration14production = 'root@localhost:22'15dest_path = '/var/www'1617# Rackspace Cloud Files configuration settings18env.cloudfiles_username = 'my_rackspace_username'19env.cloudfiles_api_key = 'my_rackspace_api_key'20env.cloudfiles_container = 'my_cloudfiles_container'2122# Github Pages configuration23env.github_pages_branch = "master"2425# Port for `serve`26PORT = 80002728def clean():29"""Remove generated files"""30if os.path.isdir(DEPLOY_PATH):31shutil.rmtree(DEPLOY_PATH)32os.makedirs(DEPLOY_PATH)3334def build():35"""Build local version of site"""36local('pelican -s pelicanconf.py')3738def rebuild():39"""`build` with the delete switch"""40local('pelican -d -s pelicanconf.py')4142def regenerate():43"""Automatically regenerate site upon file modification"""44local('pelican -r -s pelicanconf.py')4546def serve():47"""Serve site at http://localhost:8000/"""48os.chdir(env.deploy_path)4950class AddressReuseTCPServer(SocketServer.TCPServer):51allow_reuse_address = True5253server = AddressReuseTCPServer(('', PORT), ComplexHTTPRequestHandler)5455sys.stderr.write('Serving on port {0} ...\n'.format(PORT))56server.serve_forever()5758def reserve():59"""`build`, then `serve`"""60build()61serve()6263def preview():64"""Build production version of site"""65local('pelican -s publishconf.py')6667def cf_upload():68"""Publish to Rackspace Cloud Files"""69rebuild()70with lcd(DEPLOY_PATH):71local('swift -v -A https://auth.api.rackspacecloud.com/v1.0 '72'-U {cloudfiles_username} '73'-K {cloudfiles_api_key} '74'upload -c {cloudfiles_container} .'.format(**env))7576@hosts(production)77def publish():78"""Publish to production via rsync"""79local('pelican -s publishconf.py')80project.rsync_project(81remote_dir=dest_path,82exclude=".DS_Store",83local_dir=DEPLOY_PATH.rstrip('/') + '/',84delete=True,85extra_opts='-c',86)8788def gh_pages():89"""Publish to GitHub Pages"""90rebuild()91local("ghp-import -b {github_pages_branch} {deploy_path} -p".format(**env))929394