def _push_release(release_dir, destination, obj, py='python'):
    """Take a directory containing release files (openmdao package
    distributions, install scripts, etc., and place the files in the
    proper locations on the server.

    release_dir: str
        where the release file are located

    destination: str
        the location where the release files are to be placed. It can be a URL
        or a local directory

    obj: _CommObj
        an object to wrap the behaviors of run, put, etc. so calls are the
        same for local or remote release areas

    py: str
        python version to use to build index files
    """
    files = os.listdir(release_dir)
    f = fnmatch.filter(files, 'go-openmdao-*.py')
    try:
        f.remove('go-openmdao-dev.py')
    except:
        pass
    if len(f) < 1:
        raise RuntimeError("can't find go-openmdao-*.py file in release directory")
    elif len(f) > 1:
        raise RuntimeError("more than one file in release dir matches 'go-openmdao-*.py'")
    script = f[0]

    # determine version from the form of the go-openmdao-?.?.py file
    version = os.path.splitext(script)[0].split('-', 2)[2]

    # the following will barf if the version already exists on the server
    obj.run('mkdir %s/downloads/%s' % (destination, version))
    obj.run('chmod 755 %s/downloads/%s' % (destination, version))

    # push new distribs to the server
    for f in os.listdir(release_dir):
        if (f.endswith('.tar.gz') and f != 'docs.tar.gz') or f.endswith('.egg'):
            obj.put(os.path.join(release_dir,f), '%s/dists/%s' % (destination, f))
            obj.run('chmod 644 %s/dists/%s' % (destination, f))

    obj.put(os.path.join(release_dir, 'go-openmdao-%s.py' % version),
        '%s/downloads/%s/go-openmdao-%s.py' % (destination, version, version))
    obj.run('chmod 755 %s/downloads/%s/go-openmdao-%s.py' % (destination, version, version))

    # put the docs on the server
    obj.put_dir(os.path.join(release_dir, 'docs'),
                '%s/downloads/%s/docs' % (destination, version))

    obj.put(os.path.join(repo_top(),'scripts','mkdlversionindex.py'),
            '%s/downloads/%s/mkdlversionindex.py' % (destination, version))

    obj.put(os.path.join(repo_top(),'scripts','mkegglistindex.py'),
            '%s/dists/mkegglistindex.py' % destination)

    obj.put(os.path.join(repo_top(),'scripts','mkdownloadindex.py'),
            '%s/downloads/mkdownloadindex.py' % destination)

    cdir = os.getcwd()

    # update the index.html for the version download directory on the server
    dpath = '%s/downloads/%s' % (destination, version)
    obj.run('cd %s && %s mkdlversionindex.py' % (dpath, py))

    os.chdir(cdir)

    # update the index.html for the dists directory on the server
    dpath = '%s/dists' % destination
    obj.run('cd %s && %s mkegglistindex.py' % (dpath, py))

    os.chdir(cdir)

    # update the 'latest' link
    obj.run('rm -f %s/downloads/latest' % destination)
    obj.run('ln -s -f %s %s/downloads/latest' % (version, destination))

    os.chdir(cdir)

    # update the index.html for the downloads directory on the server
    dpath = '%s/downloads' % destination
    obj.run('cd %s && %s mkdownloadindex.py' % (dpath, py))
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.devtools/src/openmdao/devtools/push_release.py/_push_release/original