text / fabfile.py

from __future__ import with_statement
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.colors import green
from fabric.contrib.files import sed
from fabric.operations import prompt
def publish(file):
    local('s3cmd put --acl-public '+file+' s3://text.thejeshgn.com/'+file)
    print(green("Published! - check http://text.thejeshgn.com/"+file))
 
def sign(file):
    local('gpg --clearsign '+file)
    local('rm '+file)
    local('cp '+file+".asc "+file)
    local('rm '+file+".asc ")
 
def rename(file):
    return
   
def backup():
    commit_msg = prompt('backup message?', default='Latest changes.')
    local('hg commit -m "'+commit_msg+'"')
    local('hg push')

def verify(file):
    local('gpg --verify '+file)

def ls():
    local('s3cmd ls s3://text.thejeshgn.com')
 
def index():
    intro_txt = '''
Bunch of text files. You can find them at http://text.thejeshgn.com
and also as a mercurial repository http://code.thejeshgn.com/text
All of them are inline signed by my GPG keys. The mercurial reposiotry 
commits are also signed.

Thejesh GN <i@thejeshgn.com>
GPG keys are at : http://text.thejeshgn.com/BFFC8DD3C06DD6B0.txt
Fingerprint: C7D4 1911 9893 ADAF 27B0 FCAA BFFC 8DD3 C06D D6B0

How to validate :
1. Import my gpg keys
    >wget -O- http://text.thejeshgn.com/BFFC8DD3C06DD6B0.txt | gpg --import
        or
    >gpg --recv-keys  0xBFFC8DD3C06DD6B0

2. Check finger print
    >gpg --fingerprint 0xBFFC8DD3C06DD6B0
        it should return    
    pub   4096R/C06DD6B0 2012-01-24
    Key fingerprint = C7D4 1911 9893 ADAF 27B0  FCAA BFFC 8DD3 C06D D6B0
3. Check the signature
    >gpg --verify readme.txt 
        or
    >wget -O- http://text.thejeshgn.com/list.txt | gpg --verify
        if everything is okay it should return

    gpg: Signature made Sat 29 Sep 2012 06:12:36 PM IST using RSA key ID C06DD6B0
    gpg: Good signature from Thejesh GN (Thej) <i@thejeshgn.com>

=================== LIST OF AVAILABLE FILES ========================

'''
    local(' echo "'+intro_txt+'"  > index.txt ')
    local('s3cmd ls s3://text.thejeshgn.com >> index.txt')
    local("sed -i 's/s3:/http:/' index.txt")
    sign('index.txt')
    publish('index.txt')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.