Beispiel #1
0
    def test_run_update_update_False(self):
        lines = [
            'https://github.com/tpope/vim-pathogen.git',
            'https://github.com/vim-scripts/a.vim',
        ]

        def if_exists(name):
            return name == 'a.vim'

        mock_subproc = Mock()
        patch_lines = patch('download.load_lines', return_value=iter(lines))
        patch_subproc = patch('download.subprocess.call', mock_subproc)
        patch_exists = patch('download.bundle_exists', if_exists)

        with nested(patch_lines, patch_subproc, patch_exists):
            download.run(update=False)
            mock_subproc.assert_called_with(['git', 'clone', lines[0]])
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')
    if not os.path.exists(dpc_demo_data_path):
        zip_file_url = 'https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip?dl=1'
        import download
        download.run()
        # download_zip(zip_file_url, current_folder)

    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(ref_image, images, start_point,
                                      pixel_size, focus_to_det, scan_rows,
                                      scan_cols, scan_xstep, scan_ystep,
                                      energy, padding, weighting, solver, roi,
                                      bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    print('saving dpc output to disk in --> %s' % current_folder)
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')
    if not os.path.exists(dpc_demo_data_path):
        zip_file_url = 'https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip?dl=1'
        import download
        download.run()
        # download_zip(zip_file_url, current_folder)

    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(
        ref_image, images, start_point, pixel_size, focus_to_det, scan_rows,
        scan_cols, scan_xstep, scan_ystep, energy, padding, weighting, solver,
        roi, bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    print('saving dpc output to disk in --> %s' % current_folder)
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)
Beispiel #4
0
def handle_download(uri, dest, kwargs):
	files = download.run(uri, dest)
	if len(files) == 1:
		deploy_file(os.path.join(dest, files[0]), kwargs)
	else:
		deploy_dir(dest, kwargs)
Beispiel #5
0
def handle_download(uri, dest, kwargs):
    files = download.run(uri, dest)
    if len(files) == 1:
        deploy_file(os.path.join(dest, files[0]), kwargs)
    else:
        deploy_dir(dest, kwargs)
Beispiel #6
0
import os, sys
import cat, download, upload

# Main
if len(sys.argv) == 3:
    command = sys.argv[1]
    url = sys.argv[2]
    # switch for commands
    if command == "cat":
        cat.run(url)
    elif command == "download":
        download.run(url)
    elif command == "upload":
        upload.run(url)
    else:
        print "Invalid command"
else:
    print "Syntax: %s <command> <url>" % sys.argv[0]
Beispiel #7
0
def lfm_download(uri, dest, profile):
	if profile is not None:
		boto3.setup_default_session(profile_name=profile)
	download.run(uri, dest)