Esempio n. 1
0
def push_docs(commit_id, doc_host):
    if DEVDOCS_DIR and doc_host is not None:
        tarname = 'html.tar.gz'
        tarpath = os.path.join(get_commit_dir(commit_id), 'host_results', 
                               doc_host, tarname)
        try:
            with settings(host_string='*****@*****.**'):
                # tar up the docs so we can upload them to the server
                # put the docs on the server and untar them
                put(tarpath, '%s/%s' % (DEVDOCS_DIR, tarname))
                with cd(DEVDOCS_DIR):
                    run('tar xzf %s' % tarname)
                    run('rm -rf dev_docs')
                    run('mv html dev_docs')
                    run('rm -f %s' % tarname)
        except Exception as err:
            log('ERROR: push_docs failed: %s' % str(err))
            out = str(err)
            ret = -1
        else:
            log('push_docs was successful')
            out = 'Docs built successfully'
            ret = 0
            
        model.new_doc_info(commit_id, out)
        return out, ret
    else:
        log('push_docs was skipped')
        return '', 0 # allow update of production dev docs to be turned off during debugging
Esempio n. 2
0
def push_docs(commit_id, doc_host):
    if DEVDOCS_DIR and doc_host is not None:
        tarname = 'html.tar.gz'
        tarpath = os.path.join(get_commit_dir(commit_id), 'host_results', 
                               doc_host, tarname)
        try:
            if not os.path.isfile(tarpath):
                raise OSError("docs tar file '%s' was not found" % tarfile)
            
            cmds = [
                'tar xzf %s' % tarname,
                'rm -rf dev_docs',
                'mv html dev_docs',
                'rm -f %s' % tarname,
            ]
            
            if socket.gethostname() == DOC_DEST_HOST: # local, so don't use fabric
                print "docs are already local"
                startdir = os.getcwd()
                try:
                    print "changing dir to %s" % os.path.join(os.environ['HOME'], DEVDOCS_DIR)
                    os.chdir(os.path.join(os.environ['HOME'], DEVDOCS_DIR))
                    print "copying %s to %s" % (tarpath, tarname)
                    shutil.copy(tarpath, tarname)
                    for cmd in cmds:
                        print "running cmd: %s" % cmd
                        subprocess.check_call(cmd, cwd=os.getcwd(), shell=True)
                finally:
                    os.chdir(startdir)
            else:
                print "docs are remote.   push to doc dest host %s" % DOC_DEST_HOST
                with settings(host_string='openmdao@%s' % DOC_DEST_HOST):
                    # tar up the docs so we can upload them to the server
                    # put the docs on the server and untar them
                    put(tarpath, '%s/%s' % (DEVDOCS_DIR, tarname))
                    with cd(DEVDOCS_DIR):
                        for cmd in cmds:
                            run(cmd)
        except Exception as err:
            log('ERROR: push_docs failed: %s' % str(err))
            out = str(err)
            ret = -1
        else:
            log('push_docs was successful')
            out = 'Docs built successfully'
            ret = 0
            
        model.new_doc_info(commit_id, out)
        return out, ret
    else:
        log('push_docs was skipped')
        return '', 0 # allow update of production dev docs to be turned off during debugging