Upload with retries for intermittent JSON failures.

def _to_datalibrary_safe(fname, gi, folder_name, sample_info, config):
    """Upload with retries for intermittent JSON failures.
    """
    num_tries = 0
    max_tries = 5
    while 1:
        try:
            _to_datalibrary(fname, gi, folder_name, sample_info, config)
            break
        except (simplejson.scanner.JSONDecodeError, bioblend.galaxy.client.ConnectionError) as e:
            num_tries += 1
            if num_tries > max_tries:
                raise
            print("Retrying upload, failed with:", str(e))
            time.sleep(5)