~nskaggs/help-app/functional-test-template

« back to all changes in this revision

Viewing changes to edit-here/fabfile.py

  • Committer: Daniel Holbach
  • Date: 2015-03-19 17:54:55 UTC
  • mfrom: (111.2.14 1429896)
  • Revision ID: daniel.holbach@canonical.com-20150319175455-sjwdzzy3aqaaiu9u
mergedĀ lp:~dholbach/help-app/1429896

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from fabric.api import *
2
 
import fabric.contrib.project as project
3
 
import os
4
 
import sys
5
 
import SimpleHTTPServer
6
 
import SocketServer
7
 
 
8
 
# Local path configuration (can be absolute or relative to fabfile)
9
 
env.deploy_path = '../app/www'
10
 
DEPLOY_PATH = env.deploy_path
11
 
 
12
 
# Remote server configuration
13
 
production = 'root@localhost:22'
14
 
dest_path = '/var/www'
15
 
 
16
 
# Rackspace Cloud Files configuration settings
17
 
env.cloudfiles_username = 'my_rackspace_username'
18
 
env.cloudfiles_api_key = 'my_rackspace_api_key'
19
 
env.cloudfiles_container = 'my_cloudfiles_container'
20
 
 
21
 
 
22
 
def clean():
23
 
    if os.path.isdir(DEPLOY_PATH):
24
 
        local('rm -rf {deploy_path}'.format(**env))
25
 
        local('mkdir {deploy_path}'.format(**env))
26
 
 
27
 
def build():
28
 
    local('pelican -s pelicanconf.py')
29
 
 
30
 
def rebuild():
31
 
    clean()
32
 
    build()
33
 
 
34
 
def regenerate():
35
 
    local('pelican -r -s pelicanconf.py')
36
 
 
37
 
def serve():
38
 
    os.chdir(env.deploy_path)
39
 
 
40
 
    PORT = 8000
41
 
    class AddressReuseTCPServer(SocketServer.TCPServer):
42
 
        allow_reuse_address = True
43
 
 
44
 
    server = AddressReuseTCPServer(('', PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
45
 
 
46
 
    sys.stderr.write('Serving on port {0} ...\n'.format(PORT))
47
 
    server.serve_forever()
48
 
 
49
 
def reserve():
50
 
    build()
51
 
    serve()
52
 
 
53
 
def preview():
54
 
    local('pelican -s publishconf.py')
55
 
 
56
 
def cf_upload():
57
 
    rebuild()
58
 
    local('cd {deploy_path} && '
59
 
          'swift -v -A https://auth.api.rackspacecloud.com/v1.0 '
60
 
          '-U {cloudfiles_username} '
61
 
          '-K {cloudfiles_api_key} '
62
 
          'upload -c {cloudfiles_container} .'.format(**env))
63
 
 
64
 
@hosts(production)
65
 
def publish():
66
 
    local('pelican -s publishconf.py')
67
 
    project.rsync_project(
68
 
        remote_dir=dest_path,
69
 
        exclude=".DS_Store",
70
 
        local_dir=DEPLOY_PATH.rstrip('/') + '/',
71
 
        delete=True,
72
 
        extra_opts='-c',
73
 
    )