22
22
23
23
24
24
class TooManyChangesError (Exception ):
25
- """Exception raised when the tool is trying to apply too many changes"""
25
+ """Exception raised when the rule is trying to apply too many changes"""
26
26
27
27
def __init__ (self , bugs , changes , max_changes ):
28
- message = f"The tool has been aborted because it was attempting to apply changes on { len (changes )} bugs. Max is { max_changes } ."
28
+ message = f"The rule has been aborted because it was attempting to apply changes on { len (changes )} bugs. Max is { max_changes } ."
29
29
super ().__init__ (message )
30
30
self .bugs = bugs
31
31
self .changes = changes
@@ -43,15 +43,15 @@ class BzCleaner(object):
43
43
no_bugmail: If `True`, a token for an account that does not trigger
44
44
bugmail will be used when performing `PUT` actions on Bugzilla.
45
45
normal_changes_max: The maximum number of changes that could be made in
46
- a normal situation. If exceeded, the tool will fail.
46
+ a normal situation. If exceeded, the rule will fail.
47
47
"""
48
48
49
49
no_bugmail : bool = False
50
50
normal_changes_max : int = 50
51
51
52
52
def __init__ (self ):
53
53
super (BzCleaner , self ).__init__ ()
54
- self ._set_tool_name ()
54
+ self ._set_rule_name ()
55
55
self .apply_autofix = True
56
56
self .has_autofix = False
57
57
self .autofix_changes = {}
@@ -62,16 +62,16 @@ def __init__(self):
62
62
self .cache = Cache (self .name (), self .max_days_in_cache ())
63
63
self .test_mode = utils .get_config ("common" , "test" , False )
64
64
self .versions = None
65
- logger .info ("Run tool {}" .format (self .get_tool_path ()))
65
+ logger .info ("Run rule {}" .format (self .get_rule_path ()))
66
66
67
- def _set_tool_name (self ):
67
+ def _set_rule_name (self ):
68
68
module = sys .modules [self .__class__ .__module__ ]
69
69
base = os .path .dirname (__file__ )
70
- scripts = os .path .join (base , "scripts " )
71
- self .__tool_path__ = os .path .relpath (module .__file__ , scripts )
70
+ rules = os .path .join (base , "rules " )
71
+ self .__rule_path__ = os .path .relpath (module .__file__ , rules )
72
72
name = os .path .basename (module .__file__ )
73
73
name = os .path .splitext (name )[0 ]
74
- self .__tool_name__ = name
74
+ self .__rule_name__ = name
75
75
76
76
def init_versions (self ):
77
77
self .versions = utils .get_checked_versions ()
@@ -86,12 +86,12 @@ def description(self):
86
86
return ""
87
87
88
88
def name (self ):
89
- """Get the tool name"""
90
- return self .__tool_name__
89
+ """Get the rule name"""
90
+ return self .__rule_name__
91
91
92
- def get_tool_path (self ):
93
- """Get the tool path"""
94
- return self .__tool_path__
92
+ def get_rule_path (self ):
93
+ """Get the rule path"""
94
+ return self .__rule_path__
95
95
96
96
def needinfo_template_name (self ):
97
97
"""Get the txt template filename"""
@@ -117,7 +117,7 @@ def ignore_date(self):
117
117
return False
118
118
119
119
def must_run (self , date ):
120
- """Check if the tool must run for this date"""
120
+ """Check if the rule must run for this date"""
121
121
days = self .get_config ("must_run" , None )
122
122
if not days :
123
123
return True
@@ -129,7 +129,7 @@ def must_run(self, date):
129
129
return False
130
130
131
131
def has_enough_data (self ):
132
- """Check if the tool has enough data to run"""
132
+ """Check if the rule has enough data to run"""
133
133
if self .versions is None :
134
134
# init_versions() has never been called
135
135
return True
@@ -166,7 +166,7 @@ def exclude_no_action_bugs(self):
166
166
needinfo got ignored due to exceeding the limit). This is applied only
167
167
when using the `add_prioritized_action()` method.
168
168
169
- Returning `False` could be useful if we want to list all actions the tool
169
+ Returning `False` could be useful if we want to list all actions the rule
170
170
would do if it had no limits.
171
171
"""
172
172
return True
@@ -491,7 +491,7 @@ def get_list_bugs(self, bugs):
491
491
492
492
def get_documentation (self ):
493
493
return "For more information, please visit [BugBot documentation](https://wiki.mozilla.org/Release_Management/autonag#{})." .format (
494
- self .get_tool_path ().replace ("/" , ".2F" )
494
+ self .get_rule_path ().replace ("/" , ".2F" )
495
495
)
496
496
497
497
def has_bot_set_ni (self , bug ):
@@ -613,7 +613,7 @@ def autofix(self, bugs):
613
613
614
614
@staticmethod
615
615
def apply_changes_on_bugzilla (
616
- tool_name : str ,
616
+ rule_name : str ,
617
617
new_changes : Dict [str , dict ],
618
618
no_bugmail : bool = False ,
619
619
is_dryrun : bool = True ,
@@ -622,7 +622,7 @@ def apply_changes_on_bugzilla(
622
622
"""Apply changes on Bugzilla
623
623
624
624
Args:
625
- tool_name : the name of the tool that is performing the changes.
625
+ rule_name : the name of the rule that is performing the changes.
626
626
new_changes: the changes that will be performed. The dictionary key
627
627
should be the bug ID.
628
628
no_bugmail: If True, an account that doesn't trigger bugmail will be
@@ -651,12 +651,12 @@ def apply_changes_on_bugzilla(
651
651
time .sleep (1 )
652
652
else :
653
653
added = True
654
- db .BugChange .add (tool_name , bugid , extra = db_extra .get (bugid , "" ))
654
+ db .BugChange .add (rule_name , bugid , extra = db_extra .get (bugid , "" ))
655
655
break
656
656
if not added :
657
657
logger .error (
658
658
"%s: Cannot put data for bug %s (change => %s): %s" ,
659
- tool_name ,
659
+ rule_name ,
660
660
bugid ,
661
661
ch ,
662
662
failures ,
@@ -720,7 +720,7 @@ def _send_alert_about_too_many_changes(self, err: TooManyChangesError):
720
720
changes = err .changes .items (),
721
721
changes_size = len (err .changes ),
722
722
normal_changes_max = self .normal_changes_max ,
723
- tool_name = self .name (),
723
+ rule_name = self .name (),
724
724
https_proxy = os .environ .get ("https_proxy" ),
725
725
enumerate = enumerate ,
726
726
table_attrs = self .get_config ("table_attrs" ),
@@ -755,7 +755,7 @@ def send_email(self, date="today"):
755
755
return
756
756
757
757
if not self .has_enough_data ():
758
- logger .info ("The tool {} hasn't enough data to run" .format (self .name ()))
758
+ logger .info ("The rule {} hasn't enough data to run" .format (self .name ()))
759
759
return
760
760
761
761
login_info = utils .get_login_info ()
@@ -775,7 +775,7 @@ def send_email(self, date="today"):
775
775
dryrun = self .dryrun ,
776
776
)
777
777
except Exception :
778
- logger .exception ("Tool {}" .format (self .name ()))
778
+ logger .exception ("Rule {}" .format (self .name ()))
779
779
status = "Failure"
780
780
781
781
db .Email .add (self .name (), receivers , "global" , status )
@@ -810,7 +810,7 @@ def get_args_parser(self):
810
810
dest = "is_limited" ,
811
811
action = "store_false" ,
812
812
default = True ,
813
- help = f"If the flag is not passed, the tool will be limited to touch a maximum of { self .normal_changes_max } bugs" ,
813
+ help = f"If the flag is not passed, the rule will be limited to touch a maximum of { self .normal_changes_max } bugs" ,
814
814
)
815
815
816
816
if not self .ignore_date ():
@@ -828,7 +828,7 @@ def get_args_parser(self):
828
828
return parser
829
829
830
830
def run (self ):
831
- """Run the tool """
831
+ """Run the rule """
832
832
args = self .get_args_parser ().parse_args ()
833
833
self .parse_custom_arguments (args )
834
834
date = "" if self .ignore_date () else args .date
@@ -838,9 +838,9 @@ def run(self):
838
838
try :
839
839
self .send_email (date = date )
840
840
self .terminate ()
841
- logger .info ("Tool {} has finished." .format (self .get_tool_path ()))
841
+ logger .info ("Rule {} has finished." .format (self .get_rule_path ()))
842
842
except TooManyChangesError as err :
843
843
self ._send_alert_about_too_many_changes (err )
844
- logger .exception ("Tool %s" , self .name ())
844
+ logger .exception ("Rule %s" , self .name ())
845
845
except Exception :
846
- logger .exception ("Tool {}" .format (self .name ()))
846
+ logger .exception ("Rule {}" .format (self .name ()))
0 commit comments