

def get_file_from(url):
    trial = 0
    file_from = None
    while (trial < MAX_DOWNLOAD_RETRY):
        try:
            file_from = urllib2.urlopen(url)
            break
        except Exception:
            if is_local(trial):
                path = urlparse.urlparse(url).path
                try:
                    file_from = open(path)
                except Exception:
                    pass
                break
            else:
                trial += 1
                time.sleep(1)
    if (file_from == None):
        logger.info('Error happened while opening url {0}'.format(url))
        raise RecoDocError('Error downloading {0}'.format(url))
    elif (trial > 0):
        print('At least it was worth it')
    return file_from

dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/docutil/commands_util.py get_file_from/VarMisuse@51/66 `url`->`trial`