import py import os, sys def gendoc(pkgpath): """ generate docs """ pytestpath = pkgpath.join("bin", "py.test") pydocpath = pkgpath.join("doc") assert pytestpath.check() assert pydocpath.check() cmd = "python %s" % pytestpath cmd += " --forcegen py/doc/" old = pkgpath.dirpath().chdir() try: os.system(cmd) finally: old.chdir() return pydocpath def rsync(directory, rhost, rpath): gw = py.execnet.SshGateway(rhost) print "preparing rsync to %s, rpath %r" %(gw, rpath) #tempdir = py.test.ensuretemp('update_website_rsync_temp') #pkgpath.copy(tempdir.ensure(pkgpath.basename, dir=True)) #apidocspath.copy(tempdir.ensure(apidocspath.basename, dir=True)) rs = py.execnet.RSync(directory) rs.add_target(gw, rpath, delete=False) # True) rs.send() print "rsync completed", gw def main(pkgpath, rhost, rpath): print "generating docs for", pkgpath docbase = gendoc(pkgpath) print "rsyncing %r to %s:%s" %(docbase, rhost, rpath) rsync(docbase, rhost, rpath) if __name__ == '__main__': rhost = "codespeak.net" rbasepath = "/www/codespeak.net/htdocs/py" args = sys.argv[1:] if not args or '--help' in args or '-h' in args: print "usage: update_website.py [directory]" print print "generate py lib docs and send it to the website. " print "the 'directory' must contain the 'py' package." print "remote location will be %s/BASENAME_OF_DIRECTORY" % baselocation sys.exit() path = py.path.local(args[0]) pkgpath = path.join("py") assert pkgpath.check(), pkgpath main(pkgpath, rhost, "%s/%s" % (rbasepath, path.basename))