import urllib2
from launchpadBugs.HTMLOperations import Bug

for line in open('bugs'):
    id = int(line)
    print id
    try:
	b = Bug(id, cookie_file='.lpcookie')
	b.get_metadata()
	if 'need-i386-retrace' not in b.tags:
	    b.tags.append('need-i386-retrace')
	    b.set_metadata()
	print b.tags
    except urllib2.HTTPError, e:
	print 'fail:', id
	open('fail.log', 'a').write('%s %s\n' % (id, e))
