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
예제 #2
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)

    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
예제 #3
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 = 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
예제 #4
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
예제 #5
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