Browse Source

Fixed serious defect with parsing limit option.

avkonst 12 years ago
parent
commit
efc4aed022
3 changed files with 14 additions and 13 deletions
  1. 2 2
      mainline/core/db/utils.py
  2. 4 3
      mainline/core/warn.py
  3. 8 8
      mainline/limit.py

+ 2 - 2
mainline/core/db/utils.py

@@ -68,13 +68,13 @@ class FileRegionsMatcher(object):
         once_filter = FileRegionsDisposableGetter(prev_file_data)
         unmatched_region_ids = []
         for (ind, region) in enumerate(file_data.iterate_regions()):
-            assert(ind + 1 == region.id)
+            assert(ind + 1 == region.get_id())
             # Identify corresponding region in previous database (attempt by checksum)
             prev_id = once_filter.get_next_id_once_by_checksum(region.checksum)
             if prev_id != None:
                 self.ids.append((prev_id, False))
             else:
-                unmatched_region_ids.append(region.id)
+                unmatched_region_ids.append(region.get_id())
                 self.ids.append((None, True))
                             
         # Identify corresponding region in previous database (attempt by name)

+ 4 - 3
mainline/core/warn.py

@@ -62,7 +62,7 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
         elif options.__dict__['general.warn'] == 'all':
             self.mode = self.MODE_ALL
             
-        if self.mode != self.MODE_ALL and options.__dict__['general.db-file-prev'] == None:
+        if self.mode != self.MODE_ALL and options.__dict__['general.db_file_prev'] == None:
             self.parser.error("The mode '" + options.__dict__['general.warn'] + "' for 'general.warn' option requires 'general.db-file-prev' option set")
 
         class Limit(object):
@@ -83,14 +83,14 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
                 match = re.match(pattern, each)
                 if match == None:
                     self.parser.error("Invalid format of the 'general.max-limit' option: " + each)
-                limit = Limit("max", match.group(3), match.group(1), match.group(2), (match.group(2), '>', float(match.group(3))))
+                limit = Limit("max", float(match.group(3)), match.group(1), match.group(2), (match.group(2), '>', float(match.group(3))))
                 self.limits.append(limit)
         if options.__dict__['general.min_limit'] != None:
             for each in options.__dict__['general.min_limit']:  
                 match = re.match(pattern, each)
                 if match == None:
                     self.parser.error("Invalid format of the 'general.min-limit' option: " + each)
-                limit = Limit("min", match.group(3), match.group(1), match.group(2), (match.group(2), '<', float(match.group(3))))
+                limit = Limit("min", float(match.group(3)), match.group(1), match.group(2), (match.group(2), '<', float(match.group(3))))
                 self.limits.append(limit)
                 
     def verify_namespaces(self, valid_namespaces):
@@ -115,6 +115,7 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
             yield each   
 
     def is_mode_matched(self, limit, value, diff, is_modified):
+        print self.mode, self.MODE_TREND, limit, value, diff, is_modified
         if is_modified == None:
             return True
         if self.mode == self.MODE_ALL:

+ 8 - 8
mainline/limit.py

@@ -128,7 +128,6 @@ def main():
 
 
 def get_list_of_modified_files(loader, loader_prev):
-    modified_file_ids = []
     logging.info("Identifying changed files...")
     
     old_files_map = {}
@@ -137,20 +136,21 @@ def get_list_of_modified_files(loader, loader_prev):
     if len(old_files_map) == 0:
         return None
     
+    modified_file_ids = []
     for each in loader.iterate_file_data():
         if len(modified_file_ids) > 1000: # If more than 1000 files changed, skip optimisation
-            modified_file_ids = None
-            break
+            return None
         if (each.get_path() not in old_files_map.keys()) or old_files_map[each.get_path()] != each.get_checksum():
-            modified_file_ids.append(each.get_id())
+            modified_file_ids.append(str(each.get_id()))
+
+    old_files_map = None
             
-    if modified_file_ids != None:
+    if len(modified_file_ids) != 0:
         modified_file_ids = " , ".join(modified_file_ids)
         modified_file_ids = "(" + modified_file_ids + ")"
-    old_files_map = None
-    
-    return modified_file_ids
+        return modified_file_ids
     
+    return None
 
 def report_limit_exceeded(path, cursor, namespace, field, region_name, stat_level, trend_value, stat_limit, is_modified):
     message = "Metric '" + namespace + "/" + field + "' for region '" + region_name + "' exceeds the limit."