Commit abe95ef6 by Martin Liska Committed by Martin Liska

mark_spam.py: Mark as spam all comments done by a creator

	* mark_spam.py: Mark as spam all comments done by a creator.

From-SVN: r239527
parent 21da5261
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> 2016-08-15 Martin Liska <mliska@suse.cz>
* mark_spam.py: Add error handling and reset * mark_spam.py: Add error handling and reset
......
...@@ -39,7 +39,9 @@ def mark_as_spam(id, api_key, verbose): ...@@ -39,7 +39,9 @@ def mark_as_spam(id, api_key, verbose):
return return
# 2) mark the bug as spam # 2) mark the bug as spam
cc_list = response['bugs'][0]['cc'] bug = response['bugs'][0]
creator = bug['creator']
cc_list = bug['cc']
data = { data = {
'status': 'RESOLVED', 'status': 'RESOLVED',
'resolution': 'INVALID', 'resolution': 'INVALID',
...@@ -64,9 +66,11 @@ def mark_as_spam(id, api_key, verbose): ...@@ -64,9 +66,11 @@ def mark_as_spam(id, api_key, verbose):
# 3) mark the first comment as spam # 3) mark the first comment as spam
r = requests.get(u + '/comment') r = requests.get(u + '/comment')
response = json.loads(r.text) response = json.loads(r.text)
comment_id = response['bugs'][str(id)]['comments'][0]['id'] 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) 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}) r = requests.put(u2, json = {'comment_id': comment_id, 'add': ['spam'], 'api_key': api_key})
if verbose: if verbose:
print(r) print(r)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment