def main(argv=None):
    import paramiko.util

    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    if argv is None:
        argv = sys.argv[1:]

    parser = add_config_options(ArgumentParser())
    
    parser.add_argument("-d", "--dest", action="store", type=str, 
                        dest="dest", default='.',
                        help="destination directory where built package will go")
    parser.add_argument("-s", "--src", action="append", type=str, 
                        dest="srcs", default=[],
                        help="source directory where package is located")  
    parser.add_argument("-b", "--buildtype", action="store", type=str, 
                        dest="btype", default='bdist_egg',
                        help="type of distribution to build")
    parser.add_argument("--py", action="store", type=str, 
                        dest="py", default='python',
                        help="which python to use (default='python'")
    parser.add_argument("-k","--keep", action="store_true", dest='keep',
                        help="if there are build failures, don't delete "
                           "the temporary build directory "
                           "or terminate the remote instance if testing on EC2.")

    options = parser.parse_args()
    
    config, conn, image_hosts = process_options(options)
    
    if not options.srcs:
        print "You must specify one or more source directories"
        parser.print_help()
        sys.exit(-1)
        
    options.srcs = [os.path.abspath(os.path.expanduser(s)) for s in options.srcs]

    funct_kwargs = { 'keep': options.keep,
                     'srcdirs': options.srcs,
                     'destdir': os.path.abspath(os.path.expanduser(options.dest)), 
                     'build_type': options.btype,
                     'py': options.py,
                     }
    
    retval = run_host_processes(config, conn, image_hosts, options, 
                                funct=remote_build, 
                                funct_kwargs=funct_kwargs,
                                done_functs=[print_host_codes])
    
    if retval == 0:
        cleanup('paramiko.log')

    sys.exit(retval)
Exemplo n.º 2
0
def main(argv=None):
    import paramiko.util

    atexit.register(fabric_cleanup, True)
    paramiko.util.log_to_file('paramiko.log')
    if argv is None:
        argv = sys.argv[1:]

    parser = add_config_options(ArgumentParser())

    parser.add_argument("-d", "--dest", action="store", type=str,
                        dest="dest", default='.',
                        help="destination directory where built package will go")
    parser.add_argument("-s", "--src", action="append", type=str,
                        dest="srcs", default=[],
                        help="source directory where package is located")
    parser.add_argument("-b", "--buildtype", action="store", type=str,
                        dest="btype", default='bdist_egg',
                        help="type of distribution to build")
    parser.add_argument("--py", action="store", type=str,
                        dest="py", default='python',
                        help="which python to use (default='python'")
    parser.add_argument("-k", "--keep", action="store_true", dest='keep',
                        help="if there are build failures, don't delete "
                             "the temporary build directory "
                             "or terminate the remote instance if testing on EC2.")

    options = parser.parse_args()

    config, conn, image_hosts = process_options(options)

    if not options.srcs:
        print "You must specify one or more source directories"
        parser.print_help()
        sys.exit(-1)

    options.srcs = [os.path.abspath(os.path.expanduser(s)) for s in options.srcs]

    funct_kwargs = {'keep': options.keep,
                    'srcdirs': options.srcs,
                    'destdir': os.path.abspath(os.path.expanduser(options.dest)),
                    'build_type': options.btype,
                    'py': options.py,
                    }

    retval = run_host_processes(config, conn, image_hosts, options,
                                funct=remote_build,
                                funct_kwargs=funct_kwargs,
                                done_functs=[print_host_codes])

    if retval == 0:
        cleanup('paramiko.log')

    sys.exit(retval)
Exemplo n.º 3
0
def _build_sdist(projdir, destdir, version):
    """Build an sdist out of a develop egg and place it in destdir."""
    startdir = os.getcwd()
    try:
        os.chdir(projdir)
        # clean up any old builds
        cleanup('build')
        _build_dist('sdist', destdir)
        cleanup('build')
        if sys.platform.startswith('win'):
            os.chdir(destdir)
            # unzip the .zip file and tar it up so setuptools will find it on the server
            base = os.path.basename(projdir)+'-%s' % version
            zipname = base+'.zip'
            tarname = base+'.tar.gz'
            zarch = zipfile.ZipFile(zipname, 'r')
            zarch.extractall()
            zarch.close()
            archive = tarfile.open(tarname, 'w:gz')
            archive.add(base)
            archive.close()
            cleanup(zipname, base)
    finally:
        os.chdir(startdir)
Exemplo n.º 4
0
def _build_sdist(projdir, destdir, version):
    """Build an sdist out of a develop egg and place it in destdir."""
    startdir = os.getcwd()
    try:
        os.chdir(projdir)
        # clean up any old builds
        cleanup('build')
        _build_dist('sdist', destdir)
        cleanup('build')
        if sys.platform.startswith('win'):
            os.chdir(destdir)
            # unzip the .zip file and tar it up so setuptools will find it on the server
            base = os.path.basename(projdir) + '-%s' % version
            zipname = base + '.zip'
            tarname = base + '.tar.gz'
            zarch = zipfile.ZipFile(zipname, 'r')
            zarch.extractall()
            zarch.close()
            archive = tarfile.open(tarname, 'w:gz')
            archive.add(base)
            archive.close()
            cleanup(zipname, base)
    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
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'
        print ' or the pathname or URL of a go-openmdao-<version>.py file'
        sys.exit(-1)

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

    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"
        print " or a pathname or URL of a go-openmdao.py file"
        sys.exit(-1)

    funct_kwargs = {'keep': options.keep,
                    'testargs': options.testargs,
                    'fname': fname,
                   }
    if len(options.hosts) > 0:
        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
            # find go file and get version number
            godir = os.path.join(fname, 'downloads', 'latest')
            gfiles = os.listdir(godir)
            gfiles = fnmatch.filter(gfiles, 'go-openmdao-*.py')
            try:
                gfiles.remove('go-openmdao-dev.py')
            except:
                pass
            if len(gfiles) != 1:
                print "Need 1 go-openmdao-<version>.py file to run, but found %s" % gfiles
                sys.exit(-1)
            fname = os.path.join(fname, 'downloads', 'latest', gfiles[0])
        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)
Exemplo n.º 7
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
Exemplo n.º 8
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'
        print ' or the pathname or URL of a go-openmdao-<version>.py file'
        sys.exit(-1)

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

    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"
        print " or a pathname or URL of a go-openmdao.py file"
        sys.exit(-1)

    funct_kwargs = {
        'keep': options.keep,
        'testargs': options.testargs,
        'fname': fname,
    }
    if len(options.hosts) > 0:
        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
            # find go file and get version number
            godir = os.path.join(fname, 'downloads', 'latest')
            gfiles = os.listdir(godir)
            gfiles = fnmatch.filter(gfiles, 'go-openmdao-*.py')
            try:
                gfiles.remove('go-openmdao-dev.py')
            except:
                pass
            if len(gfiles) != 1:
                print "Need 1 go-openmdao-<version>.py file to run, but found %s" % gfiles
                sys.exit(-1)
            fname = os.path.join(fname, 'downloads', 'latest', gfiles[0])
        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)