mark_spam.py: Mark as spam all comments done by a creator
authorMartin Liska <mliska@suse.cz>
Wed, 17 Aug 2016 10:30:54 +0000 (12:30 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 17 Aug 2016 10:30:54 +0000 (10:30 +0000)
* mark_spam.py: Mark as spam all comments done by a creator.

From-SVN: r239527

contrib/ChangeLog
contrib/mark_spam.py

index 16ea455b2cf7390b8a0b3446ee100babb245616a..d2286e52e536ac9657fbd9d76110f4c7eb60244a 100644 (file)
@@ -1,3 +1,7 @@
+2016-08-17  Martin Liska  <mliska@suse.cz>
+
+       * mark_spam.py: Mark as spam all comments done by a creator.
+
 2016-08-15  Martin Liska  <mliska@suse.cz>
 
        * mark_spam.py: Add error handling and reset
index f206356ba6e3c17ecf817e5dbfb226e467903485..86f46a129ccd1377462329814ed0d1eabaa03a53 100755 (executable)
@@ -39,7 +39,9 @@ def mark_as_spam(id, api_key, verbose):
         return
 
     # 2) mark the bug as spam
-    cc_list = response['bugs'][0]['cc']
+    bug = response['bugs'][0]
+    creator = bug['creator']
+    cc_list = bug['cc']
     data = {
         'status': 'RESOLVED',
         'resolution': 'INVALID',
@@ -64,13 +66,15 @@ def mark_as_spam(id, api_key, verbose):
     # 3) mark the first comment as spam
     r = requests.get(u + '/comment')
     response = json.loads(r.text)
-    comment_id = response['bugs'][str(id)]['comments'][0]['id']
-
-    u2 = '%sbug/comment/%d/tags' % (base_url, comment_id)
-    r = requests.put(u2, json = {'comment_id': comment_id, 'add': ['spam'], 'api_key': api_key})
-    if verbose:
-        print(r)
-        print(r.text)
+    for c in response['bugs'][str(id)]['comments']:
+        if c['creator'] == creator:
+            comment_id = c['id']
+            u2 = '%sbug/comment/%d/tags' % (base_url, comment_id)
+            print(u2)
+            r = requests.put(u2, json = {'comment_id': comment_id, 'add': ['spam'], 'api_key': api_key})
+            if verbose:
+                print(r)
+                print(r.text)
 
     # 4) mark all attachments as spam
     r = requests.get(u + '/attachment')