Пример #1
0
def pdf():
    """Generate the PDF book.
    """
    set_templates(options.pdf.templates)
    run_sphinx('pdf')
    latex_dir = path(options.pdf.builddir) / 'latex'
    sh('cd %s; make' % latex_dir)
    return
Пример #2
0
def installwebsite():
    """Rebuild and copy website files to the remote server.
    """
    # Clean up
    remake_directories(options.pdf.builddir, options.website.builddir)
    # Rebuild
    call_task('website')
    # Copy to the server
    os.environ['RSYNC_RSH'] = '/usr/bin/ssh'
    src_path = path(options.website.builddir) / 'html'
    sh('cd %s; rsync --archive --delete --verbose . %s:%s' % 
        (src_path, options.website.server, options.website.server_path))
    return
Пример #3
0
def compile_gcc(source_file, target_file="a.out"):
    """Compile the source file using the gcc compiler

    return target_file and output message
    """
    command = "g++ %s -o %s 2>&1"
    if os.path.exists(target_file):
        sh('rm %s' % target_file)
    output = sh(command % (source_file, target_file), capture=True)
    if not os.path.exists(target_file):
        return None, output
    else:
        return target_file, output
Пример #4
0
def blog():
    """Generate the blog post version of the HTML for the current module.
    """
    # Clean and recreate output directory
    remake_directories(options.blog.outdir)
    outdir = path(options.blog.outdir)
    
    # Generate html from sphinx
    run_sphinx('blog')
    
    index_file = outdir / 'index.html'
    blog_file = outdir / 'blog.html'
    dry("Write blog post body to %s" % blog_file, 
        gen_blog_post, index_file=index_file, blog_file=blog_file)
    
    if 'EDITOR' in os.environ:
        sh('$EDITOR %s' % blog_file)
    return
    
Пример #5
0
def run_script(input_file, run_dir, script_name, interpreter='python'):
    """Run a script in the context of rundir relative to the
    input_file's directory, return the text output formatted to be
    included as an rst literal text block.
    """
    from paver.runtime import sh
    from paver.path import path
    docdir = path(input_file).dirname()
    output_text = sh('cd %(docdir)s/%(run_dir)s;%(interpreter)s %(script_name)s 2>&1' % vars(),
                    capture=True)
    response = '\n::\n\n\t$ %(interpreter)s %(script_name)s\n\t' % vars()
    response += '\n\t'.join(output_text.splitlines())
    while not response.endswith('\n\n'):
        response += '\n'
    return response