#!/usr/bin/python

import sys
import launchpadbugs.connector as Connector

Bug = Connector.ConnectBug()

Bug.authentication="cookies.txt"

if len(sys.argv) < 2:
	sys.exit(1)

bug = Bug(sys.argv[1])

# 1. attach comment
comment = Bug.NewComment(text="Hi,\n\n" + \
              "unfortunately your crash report didn't yield the required information. This can eventually happen. Please go ahead and submit new crash reports in future.\n\n" + \
              "Thanks for your contribution,\n" + \
              "  - Alexander\n")
bug.comments.add(comment)


# 2. invalidate status
bug.status = "Invalid"


# 3. remove CoreDump.gz attachment
found = None
count = 0
for attachment in bug.attachments:
	print "attachment: ", attachment.lp_filename
	if attachment.lp_filename == "CoreDump.gz":
		found = attachment

if found != None:
	print "found attach: ", found.id
	bug.attachments.remove(found.id)

# 4. unset private
bug.set_private(False)

# 5. commit
bug.commit(force_changes=True, ignore_lp_errors=False)

