def process_results(commit_id, returncode, results_dir, output): msg = "\n\nFull test results can be found here: %s" % os.path.join(APP_URL, 'hosts', commit_id) doc_host = None for host in os.listdir(results_dir): try: with open(os.path.join(results_dir, host, 'run.out'), 'r') as f: results = f.read() passes, fails, skips, elapsed_time = parse_test_output(results) model.new_test(commit_id, results, host, passes=passes, fails=fails, skips=skips, elapsed_time=elapsed_time) if returncode == 0 and os.path.isfile(os.path.join(results_dir, host, 'html.tar.gz')): doc_host = host except Exception as err: model.new_test(commit_id, str(err), host) try: if returncode == 0: docout, returncode = push_docs(commit_id, doc_host) # update the dev docs if the tests passed if doc_host is None: docout = '\n\nReturn code was 0 but dev docs were not built???\n' else: docout = '\n\nDev docs built successfully on host %s\n' % doc_host else: docout = "\n\nDev docs were not built\n" model.new_doc_info(commit_id, docout) except Exception as err: returncode = -1 docout = str(err) send_mail(commit_id, returncode, output+docout+msg)
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
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