Release 0.32
[0compile.git] / bugs.py
blobfcade0b041d94d95629a8cc9a90fefc75daa0460
1 # Copyright (C) 2006, Thomas Leonard
2 # See http://0install.net/0compile.html
4 import os, __main__, codecs
5 from os.path import join
7 from support import BuildEnv
9 def do_report_bug(args):
10 """report-bug"""
11 buildenv = BuildEnv()
13 log_name = join('build', 'build-failure.log')
14 build_log = codecs.open(log_name, 'r', 'utf-8')
15 log_text = build_log.read()
16 build_log.close()
18 build_env_xml_file = join(buildenv.metadir, 'build-environment.xml')
19 if os.path.exists(build_env_xml_file):
20 build_env_xml = file(build_env_xml_file)
21 log_text += '\n\nSelected versions:\n' + build_env_xml.read()
22 build_env_xml.close()
23 else:
24 log_text += '\n\n"%s" file not found' % build_env_xml_file
26 log_text = codecs.encode(log_text, 'utf-8')
28 import urllib
29 from urllib2 import urlopen
31 print "Sending contents of %s file to default bug reporting site..." % log_name
33 stream = urlopen('http://0install.net/api/report-bug/',
34 urllib.urlencode({
35 'uri': buildenv.interface,
36 'body': log_text}))
37 print stream.read()
38 stream.close()
40 __main__.commands.append(do_report_bug)