master
Raw Download raw file
 1from fabric.api import *
 2import fabric.contrib.project as project
 3import os
 4
 5# Local path configuration (can be absolute or relative to fabfile)
 6env.deploy_path = 'output'
 7DEPLOY_PATH = env.deploy_path
 8
 9# Remote server configuration
10production = 'root@localhost:22'
11dest_path = '/var/www'
12
13# Rackspace Cloud Files configuration settings
14env.cloudfiles_username = 'my_rackspace_username'
15env.cloudfiles_api_key = 'my_rackspace_api_key'
16env.cloudfiles_container = 'my_cloudfiles_container'
17
18
19def clean():
20    if os.path.isdir(DEPLOY_PATH):
21        local('rm -rf {deploy_path}'.format(**env))
22        local('mkdir {deploy_path}'.format(**env))
23
24def build():
25    local('pelican -s pelicanconf.py')
26
27def rebuild():
28    clean()
29    build()
30
31def regenerate():
32    local('pelican -r -s pelicanconf.py')
33
34def serve():
35    local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
36
37def reserve():
38    build()
39    serve()
40
41def preview():
42    local('pelican -s publishconf.py')
43
44def cf_upload():
45    rebuild()
46    local('cd {deploy_path} && '
47          'swift -v -A https://auth.api.rackspacecloud.com/v1.0 '
48          '-U {cloudfiles_username} '
49          '-K {cloudfiles_api_key} '
50          'upload -c {cloudfiles_container} .'.format(**env))
51
52@hosts(production)
53def publish():
54    local('pelican -s publishconf.py')
55    project.rsync_project(
56        remote_dir=dest_path,
57        exclude=".DS_Store",
58        local_dir=DEPLOY_PATH.rstrip('/') + '/',
59        delete=True
60    )