def build_docs(parser=None, options=None, args=None): """A script (openmdao build_docs) points to this. It generates the Sphinx documentation for openmdao. """ global _is_release if args and parser: print_sub_help(parser, 'build_docs') return -1 if options is not None and hasattr(options, 'version') and options.version: version = options.version shtitle = 'OpenMDAO Documentation v%s' % version _is_release = True else: _is_release = False try: tag, ncommits, commit = get_rev_info() version = "%s-%s-%s" % (tag, ncommits, commit) shtitle = 'OpenMDAO Documentation (%s commits after version %s)' % (ncommits, tag) except: # try to get commit id try: top = get_ancestor_dir(sys.executable, 3) if '-OpenMDAO-Framework-' in top: commit = top.split('-')[-1] version = "dev - commit id: %s" % commit shtitle = "OpenMDAO Documentation (commit id %s)" % commit else: raise RuntimeError("can't find commit id") except: version = "?-?-?" shtitle = "OpenMDAO Documentation (unknown revision)" branchdir, docdir, bindir = _get_dirnames() startdir = os.getcwd() if not os.path.isdir(docdir): raise RuntimeError('doc directory '+docdir+' not found') _write_src_docs(branchdir, docdir) _make_license_table(docdir) os.chdir(docdir) try: # make necessary directories if os.path.isdir(os.path.join('_build', 'html')): shutil.rmtree(os.path.join('_build', 'html'), onerror=onerror) if os.path.isdir(os.path.join('_build', 'doctrees')): shutil.rmtree(os.path.join('_build', 'doctrees'), onerror=onerror) os.makedirs(os.path.join('_build', 'html')) os.makedirs(os.path.join('_build', 'doctrees')) sphinx.main(argv=['-P', '-b', 'html', '-Dhtml_short_title=%s' % shtitle, '-Dversion=%s' % version, '-Drelease=%s' % version, '-d', os.path.join(docdir, '_build', 'doctrees'), docdir, os.path.join(docdir, '_build', 'html')]) finally: os.chdir(startdir)
def push_docs(parser, options, args=None): """A script (push_docs) points to this. By default it pushes the current copy of the docs up to the development doc area on openmdao.org. """ if args: print_sub_help(parser, 'push_docs') return -1 from fabric.api import run, put, cd, settings atexit.register(fabric_cleanup, True) host = options.host startdir = os.getcwd() branchdir = dirname(dirname(dirname(sys.executable))) docdir = join(branchdir, 'docs') idxpath = join(docdir, '_build', 'html', 'index.html') if not os.path.isfile(idxpath) or not options.nodocbuild: build_docs() os.chdir(join(docdir, '_build')) tarpath = tar_dir('html', 'docs', '.') tarname = os.path.basename(tarpath) with settings(host_string=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' % (options.docdir, tarname)) with cd(options.docdir): run('tar xzf %s' % tarname) run('rm -rf dev_docs') run('mv html dev_docs') run('rm -f %s' % tarname)
def list_testhosts(parser, options, args=None): if args: print_sub_help(parser, 'list_testhosts') return -1 hostlist, config = read_config(options) for host in filter_config(hostlist, config, options): plat = config.get(host, 'platform') py = config.get(host, 'py') print host.ljust(30), plat.ljust(10), py
def openmdao_docs(parser, options, args=None): if args: print_sub_help(parser, 'docs') return -1 plugin_docs(parser, options, args)
def test_branch(parser, options, args=None): if args: print_sub_help(parser, 'test_branch') return -1 atexit.register(fabric_cleanup, True) paramiko.util.log_to_file('paramiko.log') options.filters = ['test_branch==true'] config, conn, ec2_hosts = process_options(options) if not options.hosts: parser.print_help() print "nothing to do - no hosts specified" sys.exit(0) if options.fname is None: # assume we're testing the current repo print 'creating tar file of current branch: ', options.fname = os.path.join(os.getcwd(), 'OpenMDAO-Framework-testbranch.tar') ziptarname = options.fname + '.gz' cleanup(ziptarname) # clean up the old tar file make_git_archive(options.fname, prefix='OpenMDAO-OpenMDAO-Framework-testbranch/') subprocess.check_call(['gzip', options.fname]) options.fname = os.path.abspath(ziptarname) print options.fname cleanup_tar = True else: cleanup_tar = False fname = options.fname if not (fname.startswith('http') or \ fname.startswith('git:') or fname.startswith('git@')): fname = os.path.abspath(os.path.expanduser(options.fname)) if fname.endswith('.tar.gz') or fname.endswith('.tar'): if not os.path.isfile(fname): print "can't find file '%s'" % fname sys.exit(-1) elif fname.endswith('.git') or \ (fname.startswith('http') and os.path.splitext(fname)[1]==''): pass else: parser.print_help() print "\nfilename '%s' must specify a tar file or git repository" % fname sys.exit(-1) testargs = '-v ' if options.verbose else '' testargs += '--gui ' if options.gui else '' testargs += '--skip-gui ' if options.skip_gui else '' testargs += options.testargs funct_kwargs = {'keep': options.keep, 'testargs': testargs, 'fname': fname, 'remotedir': get_tmp_user_dir(), 'branch': options.branch, 'cfg': config } try: retcode = run_host_processes(config, conn, ec2_hosts, options, funct=_remote_build_and_test, funct_kwargs=funct_kwargs, done_functs=[print_host_codes]) finally: if cleanup_tar: cleanup(ziptarname) if retcode == 0: cleanup('paramiko.log') return retcode
def build_docs(parser=None, options=None, args=None): """A script (openmdao build_docs) points to this. It generates the Sphinx documentation for openmdao. """ global _is_release if args and parser: print_sub_help(parser, 'build_docs') return -1 if options is not None and hasattr(options, 'version') and options.version: version = options.version shtitle = 'OpenMDAO Documentation v%s' % version _is_release = True else: _is_release = False try: tag, ncommits, commit = get_rev_info() version = "%s-%s-%s" % (tag, ncommits, commit) shtitle = 'OpenMDAO Documentation (%s commits after version %s)' % ( ncommits, tag) except: # try to get commit id try: top = get_ancestor_dir(sys.executable, 3) if '-OpenMDAO-Framework-' in top: commit = top.split('-')[-1] version = "dev - commit id: %s" % commit shtitle = "OpenMDAO Documentation (commit id %s)" % commit else: raise RuntimeError("can't find commit id") except: version = "?-?-?" shtitle = "OpenMDAO Documentation (unknown revision)" branchdir, docdir, bindir = _get_dirnames() startdir = os.getcwd() if not os.path.isdir(docdir): raise RuntimeError('doc directory ' + docdir + ' not found') _write_src_docs(branchdir, docdir) _make_license_table(docdir) os.chdir(docdir) try: # make necessary directories if os.path.isdir(os.path.join('_build', 'html')): shutil.rmtree(os.path.join('_build', 'html'), onerror=onerror) if os.path.isdir(os.path.join('_build', 'doctrees')): shutil.rmtree(os.path.join('_build', 'doctrees'), onerror=onerror) os.makedirs(os.path.join('_build', 'html')) os.makedirs(os.path.join('_build', 'doctrees')) sphinx.main(argv=[ '-P', '-b', 'html', '-Dhtml_short_title=%s' % shtitle, '-Dversion=%s' % version, '-Drelease=%s' % version, '-d', os.path.join(docdir, '_build', 'doctrees'), docdir, os.path.join(docdir, '_build', 'html') ]) finally: os.chdir(startdir)
def test_branch(parser, options, args=None): if args: print_sub_help(parser, 'test_branch') return -1 atexit.register(fabric_cleanup, True) paramiko.util.log_to_file('paramiko.log') options.filters = ['test_branch==true'] config, conn, ec2_hosts = process_options(options) if not options.hosts: parser.print_help() print "nothing to do - no hosts specified" sys.exit(0) if options.fname is None: # assume we're testing the current repo print 'creating tar file of current branch: ', options.fname = os.path.join(os.getcwd(), 'OpenMDAO-Framework-testbranch.tar') ziptarname = options.fname + '.gz' cleanup(ziptarname) # clean up the old tar file make_git_archive(options.fname, prefix='OpenMDAO-OpenMDAO-Framework-testbranch/') subprocess.check_call(['gzip', options.fname]) options.fname = os.path.abspath(ziptarname) print options.fname cleanup_tar = True else: cleanup_tar = False fname = options.fname if not (fname.startswith('http') or \ fname.startswith('git:') or fname.startswith('git@')): fname = os.path.abspath(os.path.expanduser(options.fname)) if fname.endswith('.tar.gz') or fname.endswith('.tar'): if not os.path.isfile(fname): print "can't find file '%s'" % fname sys.exit(-1) elif fname.endswith('.git') or \ (fname.startswith('http') and os.path.splitext(fname)[1]==''): pass else: parser.print_help() print "\nfilename '%s' must specify a tar file or git repository" % fname sys.exit(-1) testargs = '-v ' if options.verbose else '' testargs += '--gui ' if options.gui else '' testargs += '--skip-gui ' if options.skip_gui else '' testargs += options.testargs funct_kwargs = { 'keep': options.keep, 'testargs': testargs, 'fname': fname, 'remotedir': get_tmp_user_dir(), 'branch': options.branch, 'cfg': config } try: retcode = run_host_processes(config, conn, ec2_hosts, options, funct=_remote_build_and_test, funct_kwargs=funct_kwargs, done_functs=[print_host_codes]) finally: if cleanup_tar: cleanup(ziptarname) if retcode == 0: cleanup('paramiko.log') return retcode