More changes for WKD.
[fsij-homepage.git] / fabfile.py
1 from fabric.api import *
2 import fabric.contrib.project as project
3 import os
4
5 # Local path configuration (can be absolute or relative to fabfile)
6 env.deploy_path = 'output'
7 DEPLOY_PATH = env.deploy_path
8
9 # Remote server configuration
10 production = 'root@localhost:22'
11 dest_path = '/var/www'
12
13 # Rackspace Cloud Files configuration settings
14 env.cloudfiles_username = 'my_rackspace_username'
15 env.cloudfiles_api_key = 'my_rackspace_api_key'
16 env.cloudfiles_container = 'my_cloudfiles_container'
17
18
19 def clean():
20     if os.path.isdir(DEPLOY_PATH):
21         local('rm -rf {deploy_path}'.format(**env))
22         local('mkdir {deploy_path}'.format(**env))
23
24 def build():
25     local('pelican -s pelicanconf.py')
26
27 def rebuild():
28     clean()
29     build()
30
31 def regenerate():
32     local('pelican -r -s pelicanconf.py')
33
34 def serve():
35     local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
36
37 def reserve():
38     build()
39     serve()
40
41 def preview():
42     local('pelican -s publishconf.py')
43
44 def 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)
53 def 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     )