Beispiel #1
0
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)

    startdir = os.getcwd()

    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 += '--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 test_branch(argv=None):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    
    if argv is None:
        argv = sys.argv[1:]
        
    parser = ArgumentParser()
    add_config_options(parser)
    parser.add_argument("-k","--keep", action="store_true", dest='keep',
                        help="Don't delete the temporary build directory. "
                             "If testing on EC2 stop the instance instead of terminating it.")
    parser.add_argument("-f","--file", action="store", type=str, 
                        dest='fname',
                        help="Pathname of a tarfile or URL of a git repo. "
                             "Defaults to the current repo.")
    parser.add_argument("-b","--branch", action="store", type=str, 
                        dest='branch',
                        help="If file is a git repo, supply branch name here")
    parser.add_argument("--testargs", action="store", type=str, dest='testargs',
                        default='',
                        help="args to be passed to openmdao test")

    options = parser.parse_args()
    
    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)
    
    startdir = os.getcwd()
    
    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(), 'testbranch.tar')
        ziptarname = options.fname+'.gz'
        cleanup(ziptarname) # clean up the old tar file
        make_git_archive(options.fname)
        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)
        
    funct_kwargs = { 'keep': options.keep,
                     'testargs': options.testargs,
                     'fname': fname,
                     'remotedir': get_tmp_user_dir(),
                     'branch': options.branch,
                     }
    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
Beispiel #3
0
def test_release(parser, options):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    cleanup_files = [os.path.join(os.getcwd(), 'paramiko.log')]

    if options.fname is None:
        print '\nyou must supply a release directory or the pathname or URL of a go-openmdao.py file'
        sys.exit(-1)

    options.filters = ['test_release==true']
    config, conn, ec2_hosts = process_options(options)

    startdir = os.getcwd()

    fname = options.fname
    if fname.startswith('http'):
        # if they cut & paste from the openmdao website, the fname
        # will be followed by #md5=..., so get rid of that part
        fname = fname.split('#')[0]
    else:
        fname = os.path.abspath(os.path.expanduser(fname))

    if fname.endswith('.py'):
        if not fname.startswith('http'):
            if not os.path.isfile(fname):
                print "can't find file '%s'" % fname
                sys.exit(-1)
    elif _is_release_dir(fname):
        pass
    elif os.path.isdir(fname):
        #create a structured release directory
        release_dir = fname.replace('rel_', 'release_')
        subprocess.check_call(['release', 'push', fname, release_dir])
        fname = options.fname = release_dir
        cleanup_files.append(release_dir)
    else:
        parser.print_help()
        print "\nfilename must be a release directory or a pathname or URL of a go-openmdao.py file"
        sys.exit(-1)

    funct_kwargs = {
        'keep': options.keep,
        'testargs': options.testargs,
        'fname': fname,
    }
    retval = 0
    if len(options.hosts) > 0:
        retval = run_host_processes(config,
                                    conn,
                                    ec2_hosts,
                                    options,
                                    funct=_remote_build_and_test,
                                    funct_kwargs=funct_kwargs,
                                    done_functs=[print_host_codes])
    else:  # just run test locally
        print 'testing locally...'
        loctst = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')
        tdir = tempfile.mkdtemp()
        cleanup_files.append(tdir)
        if os.path.isdir(fname):
            if not _is_release_dir(fname):
                fname = release_dir
            fname = os.path.join(fname, 'downloads', 'latest',
                                 'go-openmdao.py')
        cmd = [sys.executable, loctst, '-f', fname, '-d', tdir]
        if options.testargs:
            cmd.append('--testargs="%s"' % options.testargs)
        subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr)

    if options.keep:
        print "the following files/directories were not cleaned up: %s" % cleanup_files
    else:
        cleanup(*cleanup_files)
def test_release(parser, options):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    cleanup_files = [os.path.join(os.getcwd(), 'paramiko.log')]
    
    if options.fname is None:
        print '\nyou must supply a release directory or the pathname or URL of a go-openmdao.py file'
        sys.exit(-1)
        
    options.filters = ['test_release==true']
    config, conn, ec2_hosts = process_options(options)
    
    startdir = os.getcwd()
    
    fname = options.fname
    if fname.startswith('http'):
        # if they cut & paste from the openmdao website, the fname
        # will be followed by #md5=..., so get rid of that part
        fname = fname.split('#')[0]
    else:
        fname = os.path.abspath(os.path.expanduser(fname))
    
    if fname.endswith('.py'):
        if not fname.startswith('http'):
            if not os.path.isfile(fname):
                print "can't find file '%s'" % fname
                sys.exit(-1)
    elif _is_release_dir(fname):
        pass
    elif os.path.isdir(fname):
        #create a structured release directory
        release_dir = fname.replace('rel_', 'release_')
        subprocess.check_call(['release', 'push', fname, release_dir])
        fname = options.fname = release_dir
        cleanup_files.append(release_dir)
    else:
        parser.print_help()
        print "\nfilename must be a release directory or a pathname or URL of a go-openmdao.py file"
        sys.exit(-1)
        
    funct_kwargs = { 'keep': options.keep,
                     'testargs': options.testargs,
                     'fname': fname,
                   }
    retval = 0
    if len(options.hosts) > 0:
        retval = run_host_processes(config, conn, ec2_hosts, options, 
                                    funct=_remote_build_and_test, 
                                    funct_kwargs=funct_kwargs,
                                    done_functs=[print_host_codes])
    else: # just run test locally
        print 'testing locally...'
        loctst = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')
        tdir = tempfile.mkdtemp()
        cleanup_files.append(tdir)
        if os.path.isdir(fname):
            if not _is_release_dir(fname):
                fname = release_dir
            fname = os.path.join(fname, 'downloads', 'latest', 'go-openmdao.py')
        cmd = [sys.executable, loctst, '-f', fname, '-d', tdir]
        if options.testargs:
            cmd.append('--testargs="%s"' % options.testargs)
        subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr)
    
    if options.keep:
        print "the following files/directories were not cleaned up: %s" % cleanup_files
    else:
        cleanup(*cleanup_files)
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)
    
    startdir = os.getcwd()
    
    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)
        
    funct_kwargs = { 'keep': options.keep,
                     'testargs': options.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 test_branch(argv=None):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    
    if argv is None:
        argv = sys.argv[1:]
        
    parser = CfgOptionParser(usage="%prog [OPTIONS] -- [options to openmdao_test]")
    parser.add_option("-k","--keep", action="store_true", dest='keep',
                      help="Don't delete the temporary build directory. "
                           "If testing on EC2 stop the instance instead of terminating it.")
    parser.add_option("-f","--file", action="store", type='string', 
                      dest='fname',
                      help="Pathname of a tarfile or URL of a git repo. "
                           "Defaults to the current repo.")
    parser.add_option("-b","--branch", action="store", type='string', 
                      dest='branch',
                      help="If file is a git repo, supply branch name here")

    (options, args) = parser.parse_args(argv)
    
    config, conn, ec2_hosts = process_options(options, parser)
    
    if not options.hosts:
        parser.print_help()
        print "nothing to do - no hosts specified"
        sys.exit(0)
    
    startdir = os.getcwd()
    
    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(), 'testbranch.tar')
        ziptarname = options.fname+'.gz'
        cleanup(ziptarname) # clean up the old tar file
        make_git_archive(options.fname)
        subprocess.check_call(['gzip', options.fname])
        options.fname = os.path.abspath(ziptarname)
        print options.fname
        cleanup_tar = True
    else:
        cleanup_tar = False
        
    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'):
        pass
    else:
        parser.print_help()
        print "\nfilename must end in '.tar.gz', '.tar', or '.git'"
        sys.exit(-1)
        
    funct_kwargs = { 'keep': options.keep,
                     'testargs': args,
                     'fname': fname,
                     'remotedir': get_tmp_user_dir(),
                     'branch': options.branch,
                     }
    try:
        retcode = run_host_processes(config, conn, ec2_hosts, options, 
                                     funct=_remote_build_and_test, 
                                     funct_kwargs=funct_kwargs)
    finally:
        if cleanup_tar:
            cleanup(ziptarname)
    
    if retcode == 0:
        cleanup('paramiko.log')
        
    return retcode
def test_release(argv=None):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    cleanup_files = ['paramiko.log']
    
    if argv is None:
        argv = sys.argv[1:]
        
    parser = CfgOptionParser(usage="%prog [OPTIONS] -- [options to openmdao_test]")
    parser.add_option("-k","--keep", action="store_true", dest='keep',
                      help="Don't delete the temporary build directory. "
                           "If testing on EC2 stop the instance instead of terminating it.")
    parser.add_option("-f","--file", action="store", type='string', dest='fname',
                      help="URL or pathname of a go-openmdao.py file or pathname of a release dir")

    (options, args) = parser.parse_args(argv)
    
    if options.fname is None:
        parser.print_help()
        print '\nyou must supply a release directory or the pathname or URL of a go-openmdao.py file'
        sys.exit(-1)
        
    config, conn, ec2_hosts = process_options(options, parser)
    
    startdir = os.getcwd()
    
    fname = options.fname
    if fname.startswith('http'):
        # if they cut & paste from the openmdao website, the fname
        # will be followed by #md5=..., so get rid of that part
        fname = fname.split('#')[0]
    else:
        fname = os.path.abspath(os.path.expanduser(fname))
    
    if fname.endswith('.py'):
        if not fname.startswith('http'):
            if not os.path.isfile(fname):
                print "can't find file '%s'" % fname
                sys.exit(-1)
    elif _is_release_dir(fname):
        pass
    elif os.path.isdir(fname):
        #create a structured release directory
        release_dir = "%s__release" % fname
        subprocess.check_call(['push_release', fname, release_dir])
        fname = options.fname = release_dir
        cleanup_files.append(release_dir)
    else:
        parser.print_help()
        print "\nfilename must be a release directory or a pathname or URL of a go-openmdao.py file"
        sys.exit(-1)
        
    funct_kwargs = { 'keep': options.keep,
                     'testargs': args,
                     'fname': fname,
                   }
    retval = 0
    if len(options.hosts) > 0:
        retval = run_host_processes(config, conn, ec2_hosts, options, 
                                    funct=_remote_build_and_test, 
                                    funct_kwargs=funct_kwargs)
    if not options.keep:
        cleanup(*cleanup_files)
Beispiel #8
0
def test_branch(argv=None):
    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')

    if argv is None:
        argv = sys.argv[1:]

    parser = ArgumentParser()
    add_config_options(parser)
    parser.add_argument(
        "-k",
        "--keep",
        action="store_true",
        dest='keep',
        help="Don't delete the temporary build directory. "
        "If testing on EC2 stop the instance instead of terminating it.")
    parser.add_argument("-f",
                        "--file",
                        action="store",
                        type=str,
                        dest='fname',
                        help="Pathname of a tarfile or URL of a git repo. "
                        "Defaults to the current repo.")
    parser.add_argument("-b",
                        "--branch",
                        action="store",
                        type=str,
                        dest='branch',
                        help="If file is a git repo, supply branch name here")
    parser.add_argument("--testargs",
                        action="store",
                        type=str,
                        dest='testargs',
                        default='',
                        help="args to be passed to openmdao test")

    options = parser.parse_args()

    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)

    startdir = os.getcwd()

    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(), 'testbranch.tar')
        ziptarname = options.fname + '.gz'
        cleanup(ziptarname)  # clean up the old tar file
        make_git_archive(options.fname)
        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)

    funct_kwargs = {
        'keep': options.keep,
        'testargs': options.testargs,
        'fname': fname,
        'remotedir': get_tmp_user_dir(),
        'branch': options.branch,
    }
    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