[Admin Script] Backing up your SourceForge project CVS

Thomas Heller theller at python.net
Thu Feb 26 10:05:30 CET 2004


"Mike C. Fletcher" <mcfletch at rogers.com> writes:

> Attached is a simple little script.  It automates downloading nightly
> CVS tarballs for multiple projects from SourceForge (you do back up
> your project's CVS, don't you? (And if you're like me, you find going
> through the web interface to get the tarball for each project is a
> pain.))  It's by no means a particularly complex script, but no reason
> for everyone (well, everyone with lots of projects to maintain) to
> re-invent the wheel.

Very cool, thanks.
Here is a hacked version of the retrieve function, which doesn't require
the external programs bzip2 and gzip (Pytghon has enough batteries
already).

def retrieve( projectName ):
    """Given a projectName, retrieve and store download to downloadDirectory"""
    os.chdir( downloadDirectory )
    url = "http://cvs.sourceforge.net/cvstarballs/%(projectName)s-cvsroot.tar.bz2"%locals()
    date = time.strftime( '%Y-%m-%d' )
    fileName = '%(projectName)s-%(date)s-cvsroot.tar.bz2'%locals()
    file = os.path.join( downloadDirectory, fileName )
    def doDots( current, block, total ):
        sys.stdout.write( '.' )
    print 'Retrieving:\n %(url)s\nInto:\n %(fileName)s'%locals()
    urllib.urlretrieve( url, file, doDots )
    print
    print 'Decompressing bzip format'
    data = bz2.BZ2File(fileName, "r").read()
    print 'Recompressing in gzip format'
    tarFile = os.path.splitext(fileName)[0]
    gzip.GzipFile(tarFile + '.gz', "wb", 9).write(data)
    print 'Finished'

Thomas





More information about the Python-list mailing list