Esempio n. 1
0
def test_getmfexes(verify=True):
    pymake.getmfexes(mfexe_pth, verify=verify)
    for target in os.listdir(mfexe_pth):
        srcpth = os.path.join(mfexe_pth, target)
        if os.path.isfile(srcpth):
            dstpth = os.path.join(downloaded_bindir, target)
            print("copying {} -> {}".format(srcpth, dstpth))
            shutil.copy(srcpth, dstpth)
Esempio n. 2
0
def test_getmfexes():
    pymake.getmfexes(mfexe_pth)
    for target in os.listdir(mfexe_pth):
        srcpth = os.path.join(mfexe_pth, target)
        if os.path.isfile(srcpth):
            dstpth = os.path.join(ebindir, target)
            print('copying {} -> {}'.format(srcpth, dstpth))
            shutil.copy(srcpth, dstpth)
    return
Esempio n. 3
0
def test_download_and_unzip():
    error_msg = "pymake not installed - cannot download executables"
    assert pymake is not None, error_msg

    pymake.getmfexes(exe_pth, verbose=True)

    move_exe()

    return
Esempio n. 4
0
def test_download_and_unzip_and_zip():
    exclude_files = ["code.json"]
    pth = "./temp/t999"
    pymake.getmfexes(pth, verbose=True)
    for f in os.listdir(pth):
        fpth = os.path.join(pth, f)
        if not os.path.isdir(fpth) and f not in exclude_files:
            errmsg = "{} not executable".format(fpth)
            assert which(fpth) is not None, errmsg

    # zip up exe's using files
    zip_pth = os.path.join("temp", "ziptest01.zip")
    print("creating '{}'".format(zip_pth))
    success = pymake.zip_all(
        zip_pth, file_pths=[os.path.join(pth, e) for e in os.listdir(pth)])
    assert success, "could not create zipfile using file names"
    os.remove(zip_pth)

    # zip up exe's using directories
    zip_pth = os.path.join("temp", "ziptest02.zip")
    print("creating '{}'".format(zip_pth))
    success = pymake.zip_all(zip_pth, dir_pths=pth)
    assert success, "could not create zipfile using directories"
    os.remove(zip_pth)

    # zip up exe's using directories and a pattern
    zip_pth = os.path.join("temp", "ziptest03.zip")
    print("creating '{}'".format(zip_pth))
    success = pymake.zip_all(zip_pth, dir_pths=pth, patterns="mf")
    assert success, "could not create zipfile using directories and a pattern"
    os.remove(zip_pth)

    # zip up exe's using files and directories
    zip_pth = os.path.join("temp", "ziptest04.zip")
    print("creating '{}'".format(zip_pth))
    success = pymake.zip_all(
        zip_pth,
        file_pths=[os.path.join(pth, e) for e in os.listdir(pth)],
        dir_pths=pth,
    )
    assert success, "could not create zipfile using files and directories"
    os.remove(zip_pth)

    # clean up exe's
    for f in os.listdir(pth):
        fpth = os.path.join(pth, f)
        if not os.path.isdir(fpth):
            print("Removing " + f)
            os.remove(fpth)

    # clean up directory
    if os.path.isdir(pth):
        print("Removing folder " + pth)
        shutil.rmtree(pth)

    return
Esempio n. 5
0
def test_download_and_unzip():
    pymake.getmfexes(exe_pth)

    # move the exes from exe_pth to bindir
    files = os.listdir(exe_pth)
    for file in files:
        if file.startswith('__'):
            continue
        src = os.path.join(exe_pth, file)
        dst = os.path.join(bindir, file)
        print('moving {} -> {}'.format(src, dst))
        os.replace(src, dst)
Esempio n. 6
0
def test_download_and_unzip_and_zip():
    exclude_files = ['code.json']
    pth = './temp/t999'
    pymake.getmfexes(pth)
    for f in os.listdir(pth):
        fpth = os.path.join(pth, f)
        if not os.path.isdir(fpth) and f not in exclude_files:
            errmsg = '{} not executable'.format(fpth)
            assert which(fpth) is not None, errmsg

    # zip up exe's using files
    zip_pth = os.path.join('temp', 'ziptest01.zip')
    success = pymake.zip_all(
        zip_pth, file_pths=[os.path.join(pth, e) for e in os.listdir(pth)])
    assert success, 'could not create zipfile using file names'
    os.remove(zip_pth)

    # zip up exe's using directories
    zip_pth = os.path.join('temp', 'ziptest02.zip')
    success = pymake.zip_all(zip_pth, dir_pths=pth)
    assert success, 'could not create zipfile using directories'
    os.remove(zip_pth)

    # zip up exe's using directories and a pattern
    zip_pth = os.path.join('temp', 'ziptest03.zip')
    success = pymake.zip_all(zip_pth, dir_pths=pth, patterns='mf')
    assert success, 'could not create zipfile using directories and a pattern'
    os.remove(zip_pth)

    # zip up exe's using files and directories
    zip_pth = os.path.join('temp', 'ziptest04.zip')
    success = pymake.zip_all(
        zip_pth,
        file_pths=[os.path.join(pth, e) for e in os.listdir(pth)],
        dir_pths=pth)
    assert success, 'could not create zipfile using files and directories'
    os.remove(zip_pth)

    # clean up exe's
    for f in os.listdir(pth):
        fpth = os.path.join(pth, f)
        if not os.path.isdir(fpth):
            print('Removing ' + f)
            os.remove(fpth)

    # clean up directory
    if os.path.isdir(pth):
        print('Removing folder ' + pth)
        shutil.rmtree(pth)

    return
Esempio n. 7
0
import numpy as np
import matplotlib as mpl
import flopy
import pymake

# Print python package versions
flopypth = flopy.__path__[0]
pymakepth = pymake.__path__[0]
print("python version:     {}".format(sys.version))
print("numpy version:      {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version:      {}".format(flopy.__version__))
print("pymake version:     {}".format(pymake.__version__))
print("")
print("flopy is installed in:  {}".format(flopypth))
print("pymake is installed in: {}".format(pymakepth))

# Update flopy from GitHub repo
flopy.mf6.utils.generate_classes(branch="develop", backup=False)

# Get executables
bin_pth = os.path.join("..", "bin")
if not os.path.isdir(bin_pth):
    os.makedirs(bin_pth)
pymake.getmfexes(bin_pth, verbose=True)

# Replace MODFLOW 6 executables with the latest versions
url = pymake.get_repo_assets(
    "MODFLOW-USGS/modflow6-nightly-build")["linux.zip"]
pymake.download_and_unzip(url, bin_pth, verbose=True)
Esempio n. 8
0
def test_download_exes():
    pymake.getmfexes(dstpth, exes=("mfnwt", "mf6"), verbose=True)
    return
Esempio n. 9
0
def test_download_exes():
    pymake.getmfexes(dstpth, exes=("mf2005", "mfusg", "mf6"), verbose=True)
Esempio n. 10
0
def test_download_exes():
    pymake.getmfexes(dstpth, exes=('mf2005', 'mfusg', 'mf6'))
    return
Esempio n. 11
0
def test_download_exes():
    pymake.getmfexes(dstpth, exes=('mfnwt', 'mf6'))
    return