def download(url, filename, dl_progress=None, download_dir=None):
    '''download from url, saved with filename.
    if dl_progress, use it as callback for progress, otherwise use console printing
    if download_dir, use that dir, otherwise create temp one
    return: the complete filename, including path
    '''
    if not download_dir:
        download_dir = tempfile.mkdtemp()
    if not dl_progress:
        def dl_progress_callback_cmd(count, block_size, total_size):
            update_progress(min(count * block_size, total_size) / total_size,
                            total_size / (1024 ** 2))
        dl_progress_callback = dl_progress_callback_cmd
    else:
        dl_progress_callback = dl_progress
    print 'Download ', filename
    print 'from ', url
    filename = os.path.join(download_dir, filename)
    print 'download to ', filename
    urllib.urlretrieve(url, filename, reporthook=dl_progress_callback)

    return filename


# Testing download method
dataset/ETHPy150Open biicode/client/setups/setup_tools.py/download/original