Beispiel #1
0
 def __init__(self, coverage_name):
     """
     Class constructor.
     :param <string> log_file_path: the path to the log file
     :param <string> coverage_name: the name of the coverage to be searched for.
     """
     HAParser.__init__(self)
     self.coverage_name = coverage_name.lower()
 def __init__(self, log_lines):
     """
     Class constructor.
     :param list[str] log_lines: the lines of the log
     :param <string> coverage_name: the coverage for which the information is parsed.
     """
     HAParser.__init__(self, log_lines)
     self.coverage_names = HAUsedCoveragesParser(log_lines).parse_accessed_coverages()
 def __init__(self, log_lines):
     """
     Class constructor.
     :param list[str] log_lines: the lines of the log
     :param <string> coverage_name: the coverage for which the information is parsed.
     """
     HAParser.__init__(self, log_lines)
     self.coverage_names = HAUsedCoveragesParser(
         log_lines).parse_accessed_coverages()
 def parse_coverage_band_line(self, coverage_name, line):
     """
     Parses a line in the log file which already contains the coverage.
     :param <string> line: a log line in which the searched coverage is addressed.
     :return: <[HACoverageBandInfo]> list of objects describing the bands accessed in the current line.
     """
     ret = []
     if self.range_subset_key in line.lower():
         split = line.split(self.range_subset_key)
         focus = split[1]
         # check if the range subset is given in the middle of the request or at the end
         if self.and_key in focus:
             # in the middle, do further split
             focus = focus.split(self.and_key)[0]
         else:
             # otherwise focus is at the end followed by a space
             focus = focus.split(" ")[0]
         # check if there are several bands accessed
         if self.comma_key in focus:
             bands = focus.split(self.comma_key)
         elif self.column_key in focus:
             bands = focus.split(self.column_key)
         else:
             bands = [focus]
         # add all the bands to the result
         date = HAParser.parse_date(line)
         for band in bands:
             ret.append(HACoverageBandsInfo(date, coverage_name, band, 1))
     return ret
Beispiel #5
0
 def read_coverage_access_by_date(coverage_name, start_date, end_date):
     session = configmanager.session
     coverage_access = session.query(HAUsedCoveragesInfo).filter(
         (HAUsedCoveragesInfo.coverage_name == coverage_name) &
         (HAUsedCoveragesInfo.date.between(start_date, end_date))).all()
     return HAParser.merge_info_list(
         coverage_access, HAUsedCoveragesInfo.date_key)
Beispiel #6
0
 def read_coverage_bands_totals(coverage_name, start_date, end_date):
     session = configmanager.session
     coverage_bands = session.query(HACoverageBandsInfo).filter(
         (HACoverageBandsInfo.date.between(start_date, end_date)) &
         (HACoverageBandsInfo.coverage_name == coverage_name)).all()
     return HAParser.merge_info_list(
         coverage_bands, HACoverageBandsInfo.band_property_key)
Beispiel #7
0
 def parse_line(self, line):
     """
     Parses the information about bounding boxes addressed in a log line.
     :param <string> line: a log line representing a wms request.
     :return: <HABox>: the bbox corresponding to the line, None if not all the coordinates are given.
     """
     if self.wcs_bbox_key in line:
         bbox = self.extract_wcs_bbox(line)
         if bbox is not None:
             return HABboxAccessInfo(HAParser.parse_date(line), bbox, 1)
     if self.wms_bbox_key in line:
         bbox = self.extract_wms_bbox(line)
         if bbox is not None:
             return HABboxAccessInfo(HAParser.parse_date(line), bbox, 1)
     # in case there is no bbox
     return None
 def parse_coverage_band_line(self, coverage_name, line):
     """
     Parses a line in the log file which already contains the coverage.
     :param <string> line: a log line in which the searched coverage is addressed.
     :return: <[HACoverageBandInfo]> list of objects describing the bands accessed in the current line.
     """
     ret = []
     if self.range_subset_key in line.lower():
         split = line.split(self.range_subset_key)
         focus = split[1]
         # check if the range subset is given in the middle of the request or at the end
         if self.and_key in focus:
             # in the middle, do further split
             focus = focus.split(self.and_key)[0]
         else:
             # otherwise focus is at the end followed by a space
             focus = focus.split(" ")[0]
         # check if there are several bands accessed
         if self.comma_key in focus:
             bands = focus.split(self.comma_key)
         elif self.column_key in focus:
             bands = focus.split(self.column_key)
         else:
             bands = [focus]
         # add all the bands to the result
         date = HAParser.parse_date(line)
         for band in bands:
             ret.append(HACoverageBandsInfo(date, coverage_name, band, 1))
     return ret
Beispiel #9
0
 def parse_band_access_count(self, coverage_name, start_date, end_date):
     """
     Parses information about the access count on bands for the coverage/layer with the passed name.
     :param <string> coverage_name: the coverage/layer name to be analyzed.
     """
     return HAParser.print_as_json_array(
         DbReader.read_coverage_bands_totals(coverage_name, start_date,
                                             end_date))
 def parse_line(self, line, accessed_coverages):
     """
     Parses a log line, extracting information about the coverages accessed in the line.
      :param <string> line: the log line to be parsed.
      :return: <[HAUsedCoveragesInfo]> a list of objects describing the coverages accessed in this line.
     """
     ret = []
     for coverage_name in accessed_coverages:
         if coverage_name.lower() in line:
             ret.append(HAUsedCoveragesInfo(HAParser.parse_date(line), coverage_name, 1))
     return ret
Beispiel #11
0
 def parse_line(self, line, accessed_coverages):
     """
     Parses a log line, extracting information about the coverages accessed in the line.
      :param <string> line: the log line to be parsed.
      :return: <[HAUsedCoveragesInfo]> a list of objects describing the coverages accessed in this line.
     """
     ret = []
     for coverage_name in accessed_coverages:
         if coverage_name.lower() in line:
             ret.append(
                 HAUsedCoveragesInfo(HAParser.parse_date(line),
                                     coverage_name, 1))
     return ret
 def parse_bbox_access_count(self, start_date, end_date):
     """
     Parses information about the access counts of the accessed bounding boxes.
     """
     return HAParser.print_as_json_array(DbReader.read_bbox_access_totals(start_date, end_date))
Beispiel #13
0
 def read_bbox_access_totals(start_date, end_date):
     session = configmanager.session
     bbox_access = session.query(HABboxAccessInfo).filter(
         HABboxAccessInfo.date.between(start_date, end_date)).all()
     return HAParser.merge_info_list(bbox_access, HABboxAccessInfo.bbox_key)
Beispiel #14
0
 def __init__(self, log_lines):
     """
     Class constructor.
     :param list[str] log_lines: a list of log lines
     """
     HAParser.__init__(self, log_lines)
 def parse_services_access_count(self, start_date, end_date):
     """
     Parses information about the access counts of the services (rasdaman, geoserver, w*s).
     """
     return HAParser.print_as_json_array(DbReader.read_service_access_by_date(start_date, end_date))
 def __init__(self, log_lines):
     """
     Class constructor.
     :param list[str] log_lines: a list of log lines
     """
     HAParser.__init__(self, log_lines)
Beispiel #17
0
 def read_service_access_by_date(start_date, end_date):
     session = configmanager.session
     service_access = session.query(HAServiceAccessInfo).filter(
         HAServiceAccessInfo.date.between(start_date, end_date)).all()
     return HAParser.merge_info_list(service_access, HAServiceAccessInfo.date_key)
Beispiel #18
0
 def parse_used_coverages_count(self, start_date, end_date):
     """
     Parses information about the access counts of all coverages/layers.
     """
     return HAParser.print_as_json_array(
         DbReader.read_used_coverages_totals(start_date, end_date))
Beispiel #19
0
 def parse_services_access_count(self, start_date, end_date):
     """
     Parses information about the access counts of the services (rasdaman, geoserver, w*s).
     """
     return HAParser.print_as_json_array(
         DbReader.read_service_access_by_date(start_date, end_date))
Beispiel #20
0
 def parse_bbox_access_count(self, start_date, end_date):
     """
     Parses information about the access counts of the accessed bounding boxes.
     """
     return HAParser.print_as_json_array(
         DbReader.read_bbox_access_totals(start_date, end_date))
 def parse_used_coverages_count(self, start_date, end_date):
     """
     Parses information about the access counts of all coverages/layers.
     """
     return HAParser.print_as_json_array(DbReader.read_used_coverages_totals(start_date, end_date))
 def parse_band_access_count(self, coverage_name, start_date, end_date):
     """
     Parses information about the access count on bands for the coverage/layer with the passed name.
     :param <string> coverage_name: the coverage/layer name to be analyzed.
     """
     return HAParser.print_as_json_array(DbReader.read_coverage_bands_totals(coverage_name, start_date, end_date))
Beispiel #23
0
 def read_used_coverages_totals(start_date, end_date):
     session = configmanager.session
     used_coverages = session.query(HAUsedCoveragesInfo).filter(
         HAUsedCoveragesInfo.date.between(start_date, end_date)).all()
     return HAParser.merge_info_list(
         used_coverages, HAUsedCoveragesInfo.coverage_name_property_key)