

@celery.task(bind=True)
def parse_xml(self, xunit_format, launch_id, params, s3_conn=False, s3_key_name=None, file_content=None):
    try:
        if s3_conn:
            s3_connection = get_s3_connection()
            log.debug('Trying to get file from {}'.format(settings.S3_HOST))
            file_content = get_file_from_storage(s3_connection, s3_key_name).read()
            log.debug('Getting file is successful')
        log.debug('Start parsing xml {}'.format(s3_key_name))
        xml_parser_func(format=xunit_format, file_content=file_content, launch_id=launch_id, params=params)
        log.debug('Xml parsed successful')
    except ConnectionRefusedError as e:
        log.error(e)
        comment = 'There are some problems with connection to {}: "{}". '.format(settings.S3_HOST, e)
        if (parse_xml.request.retries < settings.S3_MAX_RETRIES):
            comment += 'Next try in {} min.'.format(int((settings.S3_COUNTDOWN / 60)))
            add_comment_to_launch(launch_id, comment)
            return self.retry(countdown=settings.S3_COUNTDOWN, throw=False, exc=e)
        comment += 'Please, try to send your xml later.'
        add_comment_to_launch(launch_id=launch_id, comment=comment)
    except Exception as e:
        log.error(e)
        comment = 'During xml parsing the following error is received: "{}"'.format(e)
        add_comment_to_launch(launch_id, comment)
    if s3_conn:
        finalize_launch(launch_id=launch_id)
        delete_file_from_storage(s3_key_name, s3_key_name)
        log.debug('Xml file "{}" deleted'.format(s3_key_name))
    else:
        launch = Launch.objects.get(pk=launch_id)
        launch.calculate_counts()

dataset/ETHPy150Open 2gis/badger-api/testreport/tasks.py parse_xml/VarMisuse@276/474 `s3_connection`->`s3_key_name`