Friday 25 October 2013

New Website Content

Just pushed a new version of  www.civet-labs.com live, just more content than the last parked version.

Some interesting things for us all to remember:

One:

Always have someone test your work! (Thanks James) As you are bound to forget something. 

Two:

Always have a deploy script!  It makes life so much easier.

Here is the exceptionally simple one to release www.civet-labs.com to s3.  Using boto (again)

import boto.s3.connection
import boto.s3.key
import os, sys

bucket_names = {"peek":"peek.civet-labs.com", 
           "live":"www.civet-labs.com"}

default_name = "peek"
name = ""
if len(sys.argv)>1:
    name = sys.argv[1]

if name not in bucket_names:
    name = default_name

def s3Callback(bytes_transmitted, bytes_total):
    print "\t",bytes_transmitted, bytes_total

conn = boto.s3.connection.S3Connection()
bucket = conn.get_bucket(bucket_names[name])
print "Deploying to: ", bucket

filenames = map(lambda x:os.path.join("..",x), os.listdir(".."))
for filename in filenames:
    if os.path.isfile(filename):
        print filename
        key = boto.s3.key.Key(bucket, os.path.split(filename)[1])
        key.set_contents_from_filename(filename, 
                                       cb=s3Callback,
                                       policy='public-read'
                                       )
Three:

twistd.py web --path=.

runs a much better web server than

python -m SimpleHTTPServer

for really simple testing of a static site, if you have twisted installed.

No comments: