示例#1
0
    def _get_max_complete_date(self, job):
        """ Return the max_complete_date from aws

        :param job: instance of ScheduledJob
        :type job: ScheduledJob
        """
        job_dict = job.get(s3_path=None)
        # s3_path sample: s3://bucket_name/logs/log_name/
        s3_path = job_dict.get('s3_path')
        if s3_path is None:
            return None
        bucket_name, prefix = parse_s3_path(s3_path)
        prefix_list = prefix.split("/")
        if prefix_list[-1] is not '':
            log_name = prefix_list[-1]
        else:
            log_name = prefix_list[-2]
        try:
            log_data = get_log_meta_data(bucket_name, log_name)
            return get_deep(log_data, ['log', 'max_complete_date'], None)
        except Exception:
            log_exception(
                "Exception in running scanner when getting max_complete_date in s3 path: "
                + s3_path
            )
        return None
示例#2
0
def test_get_deep(x, path_list, default_value, expected_value):
    assert schema.get_deep(x, path_list, default_value) == expected_value
示例#3
0
def test_get_deep(x, path_list, default_value, expected_value):
    assert schema.get_deep(x, path_list, default_value) == expected_value