flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kna...@apache.org
Subject [flink-jira-bot] 16/21: [hotfix] fix runtime errors & warnings in flink_jira_bot.py
Date Fri, 16 Apr 2021 09:46:28 GMT
This is an automated email from the ASF dual-hosted git repository.

knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git

commit 310b9cc2757e2ee41f0f82b1e0596f9b4cd71864
Author: Konstantin Knauf <knauf.konstantin@gmail.com>
AuthorDate: Wed Apr 14 17:56:42 2021 +0200

    [hotfix] fix runtime errors & warnings in flink_jira_bot.py
---
 flink_jira_bot.py | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index 72f13fe..f67e57e 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -21,7 +21,6 @@ import logging
 import confuse
 import os
 import abc
-import sys
 from argparse import ArgumentParser
 from pathlib import Path
 
@@ -47,7 +46,7 @@ class FlinkJiraRule:
         key = issue["key"]
 
         if not self.is_dry_run:
-            self.jira.update_issue_field(key, fields)
+            self.jira_client.update_issue_field(key, fields)
         else:
             logging.info(f'DRY RUN ({key}): Adding label "{label}".')
 
@@ -58,7 +57,7 @@ class FlinkJiraRule:
         key = issue["key"]
 
         if not self.is_dry_run:
-            self.jira.update_issue_field(key, fields)
+            self.jira_client.update_issue_field(key, fields)
         else:
             logging.info(
                 f'DRY RUN ({key}): Replace label "{old_label}" for "{new_label}".'
@@ -66,13 +65,13 @@ class FlinkJiraRule:
 
     def add_comment(self, key, comment):
         if not self.is_dry_run:
-            jira.issue_add_comment(key, comment)
+            self.jira_client.issue_add_comment(key, comment)
         else:
             logging.info(f'DRY_RUN ({key}): Adding comment "{comment}".')
 
     def close_issue(self, key):
         if not self.is_dry_run:
-            jira.issue_transition(key, "Closed")
+            self.jira_client.issue_transition(key, "Closed")
         else:
             logging.info(f"DRY_RUN (({key})): Closing.")
 
@@ -88,6 +87,7 @@ class Rule3(FlinkJiraRule):
         self.warning_days = config["stale_minor"]["warning_days"].get()
         self.warning_label = config["stale_minor"]["warning_label"].get()
         self.done_label = config["stale_minor"]["done_label"].get()
+        self.done_comment = config["stale_minor"]["done_comment"].get()
         self.warning_comment = config["stale_minor"]["warning_comment"].get()
 
     def run(self):
@@ -96,7 +96,10 @@ class Rule3(FlinkJiraRule):
 
     def close_tickets_marked_stale(self):
 
-        minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution
= Unresolved AND labels in ("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
+        minor_tickets_marked_stale = (
+            f"project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in
"
+            f'("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
+        )
         logging.info(
             f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
         )
@@ -120,7 +123,10 @@ class Rule3(FlinkJiraRule):
 
     def mark_stale_tickets_stale(self):
 
-        stale_minor_tickets = f"project = FLINK AND Priority = Minor AND resolution = Unresolved
AND updated < startOfDay(-{self.stale_days}d)"
+        stale_minor_tickets = (
+            f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated
< "
+            f"startOfDay(-{self.stale_days}d)"
+        )
         logging.info(
             f"Looking for minor tickets, which are stale: {stale_minor_tickets}"
         )
@@ -145,15 +151,11 @@ class Rule3(FlinkJiraRule):
 
             else:
                 logging.info(
-                    f"Found https://issues.apache.org/jira/browse/{key}, but is has recently
updated Subtasks. Ignoring for now."
+                    f"Found https://issues.apache.org/jira/browse/{key}, but is has recently
updated Subtasks. "
+                    f"Ignoring for now."
                 )
 
 
-def is_dry_run():
-    opts = [opt for opt in sys.argv[1:] if opt.startswith("-")]
-    return "-d" in opts
-
-
 def get_args():
     parser = ArgumentParser(description="Apache Flink Jira Bot")
     parser.add_argument(
@@ -179,8 +181,8 @@ if __name__ == "__main__":
 
     args = get_args()
 
-    config = confuse.Configuration("flink-jira-bot", __name__)
-    config.set_file(args.config)
+    jira_bot_config = confuse.Configuration("flink-jira-bot", __name__)
+    jira_bot_config.set_file(args.config)
 
     jira = Jira(
         url="https://issues.apache.org/jira",
@@ -188,5 +190,5 @@ if __name__ == "__main__":
         password=os.environ["JIRA_PASSWORD"],
     )
 
-    rule_3 = Rule3(jira, config, args.dryrun)
+    rule_3 = Rule3(jira, jira_bot_config, args.dryrun)
     rule_3.run()

Mime
View raw message