Browse Source

cherry picking reportbug/ dir

suites/jessie-proposed-backports
Sandro Tosi 14 years ago
parent
commit
e9d09f98d0
  1. 30
      reportbug/__init__.py
  2. 173
      reportbug/bugreport.py
  3. 7
      reportbug/checkbuildd.py
  4. 11
      reportbug/checkversions.py
  5. 54
      reportbug/debianbts.py
  6. 1
      reportbug/exceptions.py
  7. 7
      reportbug/hiermatch.py
  8. 17
      reportbug/submit.py
  9. 4
      reportbug/tempfiles.py
  10. 25
      reportbug/ui/__init__.py
  11. 1
      reportbug/ui/newt.py
  12. 13
      reportbug/ui/text.py
  13. 32
      reportbug/ui/urwid.py
  14. 8
      reportbug/urlutils.py
  15. 180
      reportbug/utils.py

30
reportbug/__init__.py

@ -0,0 +1,30 @@
#!/usr/bin/python
# -*- python -*-
# reportbug - Report a bug in the Debian distribution.
# Written by Chris Lawrence <lawrencc@debian.org>
# Copyright (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
LICENSE="""\
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appears in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation.
I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE."""
__all__ = ['bugreport', 'utils', 'urlutils', 'checkbuildd', 'checkversions',
'debianbts', 'exceptions', 'submit', 'tempfile']
VERSION_NUMBER = "3.99.0"
VERSION = "reportbug "+VERSION_NUMBER
COPYRIGHT = VERSION + '\nCopyright (C) 1999-2008 Chris Lawrence <lawrencc@debian.org>'

173
reportbug/bugreport.py

@ -0,0 +1,173 @@
#
# bugreport module - object containing bug stuff for reporting
# Written by Chris Lawrence <lawrencc@debian.org>
# Copyright (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
## Permission to use, copy, modify, and distribute this software and its
## documentation for any purpose and without fee is hereby granted,
## provided that the above copyright notice appears in all copies and that
## both that copyright notice and this permission notice appear in
## supporting documentation.
##
## I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
## BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
## DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
## SOFTWARE.
#
# $Id: reportbug.py,v 1.35.2.24 2008-04-18 05:38:28 lawrencc Exp $
import os
import utils
import debianbts
import commands
from exceptions import *
class bugreport(object):
"Encapsulates a bug report into a convenient object we can pass around."
# Default character set for str(x)
charset = 'utf-8'
def __init__(self, package, subject='', body='', system='debian',
incfiles='', sysinfo=True,
followup=False, type='debbugs', mode=utils.MODE_STANDARD,
**props):
self.type = type
for (k, v) in props.iteritems():
setattr(self, k, v)
self.package = package
self.subject = subject
self.followup = followup
self.body = body
self.mode = mode
self.system = system
self.incfiles = incfiles
self.sysinfo = sysinfo
def tset(self, value):
if value not in ('debbugs', 'launchpad'):
raise AttributeError, 'invalid report type'
self.__type = value
def tget(self):
return self.__type
type = property(tget, tset)
def __unicode__(self):
un = os.uname()
debinfo = u''
shellpath = utils.realpath('/bin/sh')
locinfo = []
langsetting = os.environ.get('LANG', 'C')
allsetting = os.environ.get('LC_ALL', '')
for setting in ('LANG', 'LC_CTYPE'):
if setting == 'LANG':
env = langsetting
else:
env = '%s (charmap=%s)' % (os.environ.get(setting, langsetting), commands.getoutput("locale charmap"))
if allsetting and env:
env = "%s (ignored: LC_ALL set to %s)" % (env, allsetting)
else:
env = allsetting or env
locinfo.append('%s=%s' % (setting, env))
locinfo = ', '.join(locinfo)
if debianbts.SYSTEMS[self.system].has_key('namefmt'):
package = debianbts.SYSTEMS[self.system]['namefmt'] % self.package
ph = getattr(self, 'pseudoheaders', None)
if ph:
headers = u'\n'.join(ph)+u'\n'
else:
headers = u''
version = getattr(self, 'version', None)
if version:
headers += u'Version: %s\n' % version
body = getattr(self, 'body', u'')
if self.mode < utils.MODE_ADVANCED:
body = NEWBIELINE+u'\n\n'+body
elif not body:
body = u'\n'
if not self.followup:
for (attr, name) in dict(severity='Severity',
justification='Justification',
tags='Tags',
filename='File').iteritems():
a = getattr(self, attr, None)
if a:
headers += u'%s: %s\n' % (name, a)
report = u"Package: %s\n%s\n" % (self.package, headers)
else:
report = "Followup-For: Bug #%d\nPackage: %s\n%s\n" % (
self.followup, self.package, headers)
infofunc = debianbts.SYSTEMS[self.system].get('infofunc', debianbts.generic_infofunc)
if infofunc:
debinfo += infofunc()
if un[0] == 'GNU':
# Use uname -v on Hurd
uname_string = un[3]
else:
kern = un[0]
if kern.startswith('GNU/'):
kern = kern[4:]
uname_string = '%s %s' % (kern, un[2])
if kern == 'Linux':
kinfo = []
if 'SMP' in un[3]:
cores = utils.get_cpu_cores()
if cores > 1:
kinfo += ['SMP w/%d CPU cores' % cores]
else:
kinfo += ['SMP w/1 CPU core']
if 'PREEMPT' in un[3]:
kinfo += ['PREEMPT']
if kinfo:
uname_string = '%s (%s)' % (uname_string, '; '.join(kinfo))
if uname_string:
debinfo += u'Kernel: %s\n' % uname_string
if locinfo:
debinfo += u'Locale: %s\n' % locinfo
if shellpath != '/bin/sh':
debinfo += u'Shell: /bin/sh linked to %s\n' % shellpath
# Don't include system info for certain packages
if self.sysinfo:
report = u"%s%s%s\n-- System Information:\n%s" % (report, body, self.incfiles, debinfo)
else:
report = u"%s%s%s" % (report, body, self.incfiles)
if hasattr(self, 'depinfo'):
report += self.depinfo
if hasattr(self, 'confinfo'):
report += self.confinfo
return report
def __str__(self):
return unicode(self).encode(charset, 'replace')
def __repr__(self):
params = ['%s=%s' % (k, self.k) for k in dir(self)]
return 'bugreport(%s)' % ', '.join(params)

7
reportbug/checkbuildd.py

@ -1,9 +1,8 @@
#
# reportbuglib/checkbuildd.py
# Check buildd.debian.org for successful past builds
# checkbuildd.py - Check buildd.debian.org for successful past builds
#
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 2002 Chris Lawrence
# (C) 2002-08 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -27,7 +26,7 @@ import sgmllib
import commands
from urlutils import open_url
from reportbug_exceptions import (
from reportbug.exceptions import (
NoNetwork,
)

11
reportbug/checkversions.py

@ -1,9 +1,8 @@
#
# reportbuglib/checkversions.py
# Find if the installed version of a package is the latest
# checkversions.py - Find if the installed version of a package is the latest
#
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 2002-06 Chris Lawrence
# (C) 2002-08 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -33,9 +32,9 @@ import sgmllib
import gc
import time
import reportbug
import utils
from urlutils import open_url
from reportbug_exceptions import (
from reportbug.exceptions import (
NoNetwork,
)
@ -301,7 +300,7 @@ def check_available(package, version, dists=None, check_incoming=True,
stuff = get_versions_available(package, dists, http_proxy, arch)
avail.update(stuff)
if check_newqueue:
srcpackage = reportbug.get_source_name(package)
srcpackage = utils.get_source_name(package)
if srcpackage is None:
srcpackage = package
stuff = get_newqueue_available(srcpackage, dists, http_proxy, arch)

54
reportbug/debianbts.py

@ -1,9 +1,8 @@
#
# reportbuglib/debianbts.py
# Routines to deal with the debbugs web pages
# debianbts.py - Routines to deal with BTS web pages
#
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 1999-2006 Chris Lawrence
# (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -25,6 +24,7 @@
#
# $Id: debianbts.py,v 1.24.2.15 2008-04-18 05:38:27 lawrencc Exp $
import utils
import sys
import mailbox
import email
@ -39,9 +39,8 @@ import urllib
import textwrap
import pprint
import reportbug
import checkversions
from reportbug_exceptions import (
from exceptions import (
NoNetwork,
)
from urlutils import open_url
@ -245,14 +244,14 @@ def handle_debian_ftp(package, bts, ui, fromaddr, online=True, http_proxy=None):
return
ui.ewrite('Checking status database...\n')
info = reportbug.get_package_status(package)
info = utils.get_package_status(package)
available = info[1]
query = False
if not available:
info = reportbug.get_source_package(package)
info = utils.get_source_package(package)
if info:
info = reportbug.get_package_status(info[0][0])
info = utils.get_package_status(info[0][0])
if not info:
cont = ui.select_options(
@ -362,7 +361,7 @@ def handle_wnpp(package, bts, ui, fromaddr, online=True, http_proxy=None):
if not package: return
ui.ewrite('Checking status database...\n')
info = reportbug.get_package_status(package)
info = utils.get_package_status(package)
available = info[1]
severity = 'normal'
@ -397,9 +396,9 @@ def handle_wnpp(package, bts, ui, fromaddr, online=True, http_proxy=None):
severity = 'normal'
query = False
if not available:
info = reportbug.get_source_package(package)
info = utils.get_source_package(package)
if info:
info = reportbug.get_package_status(info[0][0])
info = utils.get_package_status(info[0][0])
if not info:
cont = ui.select_options(
@ -441,6 +440,28 @@ def handle_wnpp(package, bts, ui, fromaddr, online=True, http_proxy=None):
return (subject, severity, headers, pseudos, body, query)
def dpkg_infofunc():
debarch = utils.get_arch()
if debarch:
utsmachine = os.uname()[4]
if utsmachine == debarch:
debinfo = u'Architecture: %s\n\n' % debarch
else:
debinfo = u'Architecture: %s (%s)\n\n' % (debarch, utsmachine)
else:
debinfo = u'Architecture: ? (%s)\n\n' % utsmachine
return debinfo
def debian_infofunc():
return utils.get_debian_release_info() + dpkg_infofunc()
def ubuntu_infofunc():
return utils.lsb_release_info() + dpkg_infofunc()
def generic_infofunc():
utsmachine = os.uname(4)
return utils.lsb_release_info() + u'Architecture: %s\n\n' % utsmachine
# Supported servers
# Theoretically support for GNATS and Jitterbug could be added here.
SYSTEMS = { 'debian' :
@ -455,13 +476,14 @@ SYSTEMS = { 'debian' :
'deppkgs' : ('gcc', 'g++', 'cpp', 'gcj', 'gpc', 'gobjc',
'chill', 'gij', 'g77', 'python', 'python-base',
'x-window-system-core', 'x-window-system'),
'cgiroot' : 'http://bugs.debian.org/cgi-bin/' },
'progeny' :
{ 'name' : 'Progeny', 'email' : 'bugs@progeny.com',
'type' : 'gnats', 'otherpkgs' : progenyother },
'cgiroot' : 'http://bugs.debian.org/cgi-bin/',
'infofunc' : debian_infofunc,
},
'ubuntu' :
{ 'name' : 'Ubuntu', 'email' : 'ubuntu-users@lists.ubuntu.com',
'type' : 'mailto' },
'type' : 'mailto',
'infofunc' : ubuntu_infofunc,
},
'guug' :
{ 'name' : 'GUUG (German Unix User Group)',
'email' : '%s@bugs.guug.de', 'query-dpkg' : False },

1
reportbug/exceptions.py

@ -1,4 +1,3 @@
# reportbuglib/reportbug_exceptions.py
# Exceptions for reportbug
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 2002-04 Chris Lawrence

7
reportbug/hiermatch.py

@ -1,8 +1,7 @@
# Doing match on a list of string or a hierarchy.
import re
from reportbuglib import reportbug_exceptions
import exceptions
def egrep_list(strlist, pattern_str, subindex=None):
"""Use the pattern_str to find any match in a list of strings."""
@ -14,8 +13,8 @@ def egrep_list(strlist, pattern_str, subindex=None):
try:
pat = re.compile(pattern_str, re.I|re.M)
except:
raise reportbug_exceptions.InvalidRegex
raise exceptions.InvalidRegex
resultlist = []
if subindex is None:
subindex = range(len(strlist))

17
reportbug/submit.py

@ -1,4 +1,4 @@
# reportbuglib/reportbug_submit module - email and GnuPG functions
# reportbug_submit module - email and GnuPG functions
# Written by Chris Lawrence <lawrencc@debian.org>
# Copyright (C) 1999-2006 Chris Lawrence
#
@ -39,18 +39,13 @@ from email.MIMEMessage import MIMEMessage
from email.Header import Header
import mimetypes
from reportbuglib import reportbug
from reportbuglib.reportbug import VERSION, VERSION_NUMBER
from reportbuglib import debianbts
from reportbuglib.rbtempfile import (
TempFile,
open_write_safe,
tempfile_prefix,
)
from reportbuglib.reportbug_exceptions import (
from __init__ import VERSION, VERSION_NUMBER
import debianbts
from tempfiles import TempFile, open_write_safe, tempfile_prefix
from exceptions import (
NoMessage,
)
from reportbuglib import reportbug_ui_text as ui
import ui.text as ui
quietly = False

4
reportbug/tempfiles.py

@ -1,7 +1,7 @@
#
# reportbuglib/rbtempfile module - Temporary file handling for reportbug
# tempfiles module - Temporary file handling for reportbug
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 1999-2004 Chris Lawrence
# (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#

25
reportbug/ui/__init__.py

@ -0,0 +1,25 @@
#!/usr/bin/python -S
# -*- python -*-
# reportbug - Report a bug in the Debian distribution.
# Written by Chris Lawrence <lawrencc@debian.org>
# Copyright (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
## Permission to use, copy, modify, and distribute this software and its
## documentation for any purpose and without fee is hereby granted,
## provided that the above copyright notice appears in all copies and that
## both that copyright notice and this permission notice appear in
## supporting documentation.
##
## I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
## BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
## DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
## SOFTWARE.
#
# $Id: reportbug.py,v 1.35.2.24 2008-04-18 05:38:28 lawrencc Exp $
__all__ = ['text', 'urwid']

1
reportbug/ui/newt.py

@ -23,7 +23,6 @@
import sys
import commands
import string
import debianbts
from reportbug_exceptions import (
UINotImportable,

13
reportbug/ui/text.py

@ -1,7 +1,6 @@
# reportbuglib/reportbug_ui_text.py
# Text user interface for reportbug
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 2001-06 Chris Lawrence
# (C) 2001-08 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -36,14 +35,12 @@ try:
except ImportError:
readline = None
import reportbug
import debianbts
from reportbug_exceptions import (
from .. import debianbts, utils, hiermatch
from ..exceptions import (
NoReport, NoPackage, NoBugs, NoNetwork,
InvalidRegex,
)
from urlutils import launch_browser
import hiermatch
from ..urlutils import launch_browser
ISATTY = sys.stdin.isatty()
charset = 'us-ascii'
@ -896,7 +893,7 @@ def spawn_editor(message, filename, editor, charset='utf-8'):
for (lineno, line) in enumerate(file(filename)):
if line == '\n' and not ourline:
ourline = lineno + 2
elif line.strip() == reportbug.NEWBIELINE:
elif line.strip() == utils.NEWBIELINE:
ourline = lineno + 2
opts = ''

32
reportbug/ui/urwid.py

@ -1,7 +1,6 @@
# reportbuglib/reportbug_ui_urwid.py
# urwid user interface for reportbug
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 2006 Chris Lawrence
# (C) 2006-08 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -28,16 +27,17 @@
import sys
import re
import getpass
import reportbug
from reportbug_exceptions import (
from .. import utils
from ..exceptions import (
UINotImportable,
NoPackage, NoBugs, NoNetwork, NoReport,
)
from urlutils import launch_browser
from reportbug_ui_text import (
from ..urlutils import launch_browser
from text import (
ewrite,
spawn_editor,
)
from ..__init__ import VERSION
try:
import urwid.raw_display
@ -294,7 +294,7 @@ def display_message(message, *args, **kwargs):
chunks = [re.sub(r'\s+', ' ', x).strip() for x in chunks]
message = '\n\n'.join(chunks).strip()
box = displaybox('', long_message=message, title=title or reportbug.VERSION)
box = displaybox('', long_message=message, title=title or VERSION)
box.show(ui)
def long_message(message, *args, **kwargs):
@ -316,7 +316,7 @@ def long_message(message, *args, **kwargs):
chunks = [re.sub(r'\s+', ' ', x).strip() for x in chunks]
message = '\n\n'.join(chunks).strip()
box = dialog('', long_message=message, title=title or reportbug.VERSION)
box = dialog('', long_message=message, title=title or VERSION)
box.add_buttons([ ("OK", 0) ])
box.main(ui)
@ -326,7 +326,7 @@ display_report = long_message
def select_options(msg, ok, help=None, allow_numbers=False, nowrap=False,
ui=None, title=None):
box = dialog('', long_message=msg, height=('relative', 80),
title=title or reportbug.VERSION)
title=title or VERSION)
if not help:
help = {}
@ -343,7 +343,7 @@ def select_options(msg, ok, help=None, allow_numbers=False, nowrap=False,
return result
def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False, ui=None):
box = dialog('', long_message=msg+"?", title=reportbug.VERSION)
box = dialog('', long_message=msg+"?", title=VERSION)
box.add_buttons([ ('Yes', True), ('No', False) ], default=1-int(default))
result = box.main(ui)
return result
@ -351,9 +351,9 @@ def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False, ui=None):
def get_string(prompt, options=None, title=None, force_prompt=False,
default='', ui=None):
if title:
title = '%s: %s' % (reportbug.VERSION, title)
title = '%s: %s' % (VERSION, title)
else:
title = reportbug.VERSION
title = VERSION
box = textentry(prompt, title=title)
box.add_buttons([ ("OK", 0) ])
@ -363,9 +363,9 @@ def get_string(prompt, options=None, title=None, force_prompt=False,
def get_multiline(prompt, options=None, title=None, force_prompt=False,
ui=None):
if title:
title = '%s: %s' % (reportbug.VERSION, title)
title = '%s: %s' % (VERSION, title)
else:
title = reportbug.VERSION
title = VERSION
box = textentry(prompt, multiline=True)
box.add_buttons([ ("OK", 0) ])
@ -388,9 +388,9 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
default = ''
if title:
title = '%s: %s' % (reportbug.VERSION, title)
title = '%s: %s' % (VERSION, title)
else:
title = reportbug.VERSION
title = VERSION
if isinstance(options, dict):
options = options.copy()

8
reportbug/urlutils.py

@ -2,7 +2,7 @@
# urlutils.py - Simplified urllib handling
#
# Written by Chris Lawrence <lawrencc@debian.org>
# (C) 1999-2006 Chris Lawrence
# (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -33,11 +33,13 @@ import os
import sys
import webbrowser
from reportbug_exceptions import (
from exceptions import (
NoNetwork,
)
UA_STR = 'reportbug/##VERSION## (Debian)'
from __init__ import VERSION_NUMBER
UA_STR = 'reportbug/'+VERSION_NUMBER+' (Debian)'
def decode (page):
"gunzip or deflate a compressed page"

180
reportbug/utils.py

@ -1,9 +1,7 @@
#
# reportbuglib/reportbug.py
# Common functions for reportbug and greportbug
#
# utils module - common functions for reportbug UIs
# Written by Chris Lawrence <lawrencc@debian.org>
# Copyright (C) 1999-2006 Chris Lawrence
# Copyright (C) 1999-2008 Chris Lawrence
#
# This program is freely distributable per the following license:
#
@ -25,10 +23,6 @@
#
# $Id: reportbug.py,v 1.35.2.24 2008-04-18 05:38:28 lawrencc Exp $
VERSION = "reportbug ##VERSION##"
VERSION_NUMBER = "##VERSION##"
COPYRIGHT = VERSION + '\nCopyright (C) 1999-2006 Chris Lawrence <lawrencc@debian.org>'
import sys
import os
import re
@ -38,9 +32,10 @@ import shlex
import rfc822
import socket
import subprocess
import imp
import debianbts
from string import ascii_letters, digits
from tempfiles import TempFile, tempfile_prefix
# Paths for dpkg
DPKGLIB = '/var/lib/dpkg'
@ -51,14 +46,19 @@ STATUSDB = os.path.join(DPKGLIB, 'status')
PSEUDOHEADERS = ('Package', 'Version', 'Severity', 'File', 'Tags',
'Justification', 'Followup-For', 'Owner', 'User', 'Usertags')
VALID_UIS = ['newt', 'text', 'gnome2', 'urwid']
AVAILABLE_UIS = VALID_UIS
for ui in VALID_UIS:
module_name = 'reportbug_ui_%(ui)s' % vars()
try:
imp.find_module(module_name)
except ImportError:
AVAILABLE_UIS.remove(ui)
AVAILABLE_UIS = ['text']
try:
import ui.urwid
AVAILABLE_UIS.append('urwid')
except:
pass
try:
import ui.gnome2
AVAILABLE_UIS.append('gnome2')
except:
pass
UIS = {'text': 'A text-oriented console interface',
'urwid': 'A menu-based console interface',
@ -688,6 +688,9 @@ def get_debian_release_info():
return debinfo
def lsb_release_info():
return commands.getoutput('lsb_release -a 2>/den/null')
def get_arch():
arch = commands.getoutput('COLUMNS=79 dpkg --print-installation-architecture 2>/dev/null')
if not arch:
@ -703,137 +706,18 @@ def generate_blank_report(package, pkgversion, severity, justification,
system='debian', exinfo=0, type=None, klass='',
subject='', tags='', body='', mode=MODE_EXPERT,
pseudos=None):
un = os.uname()
utsmachine = un[4]
debinfo = u''
shellpath = realpath('/bin/sh')
locinfo = []
langsetting = os.environ.get('LANG', 'C')
allsetting = os.environ.get('LC_ALL', '')
for setting in ('LANG', 'LC_CTYPE'):
if setting == 'LANG':
env = langsetting
else:
env = '%s (charmap=%s)' % (os.environ.get(setting, langsetting), commands.getoutput("locale charmap"))
if allsetting and env:
env = "%s (ignored: LC_ALL set to %s)" % (env, allsetting)
else:
env = allsetting or env
locinfo.append('%s=%s' % (setting, env))
locinfo = ', '.join(locinfo)
if debianbts.SYSTEMS[system].has_key('namefmt'):
package = debianbts.SYSTEMS[system]['namefmt'] % package
if pseudos:
headers = u'\n'.join(pseudos)+u'\n'
else:
headers = u''
if pkgversion:
headers += u'Version: %s\n' % pkgversion
if not exinfo:
if severity:
headers += u'Severity: %s\n' % severity
if justification:
headers += u'Justification: %s\n' % justification
if tags:
headers += u'Tags: %s\n' % tags
if foundfile:
headers += u'File: %s\n' % foundfile
if mode < MODE_ADVANCED:
body = NEWBIELINE+u'\n\n'+body
report = "\n"
if not exinfo:
if type == 'gnats':
report = ">Synopsis: %s\n>Confidential: no\n" % subject
if package == 'debian-general':
report += ">Category: %s\n" % package
else:
report += ">Category: debian-packages\n"\
">Release: %s_%s\n" % (package, pkgversion)
if severity:
report += ">" + ('Severity: %s\n' % severity)
if klass:
report += ">Class: %s\n" % klass
report += (
">Description:\n\n"
" <describe the bug here; use as many lines as you need>\n\n"
">How-To-Repeat:\n\n"
" <show how the bug is triggered>\n\n"
">Fix:\n\n"
" <if you have a patch or solution, put it here>\n\n"
">Environment:\n")
else:
report = "Package: %s\n%s\n" % (package, headers)
else:
report = "Followup-For: Bug #%d\nPackage: %s\n%s\n" % (
exinfo, package, headers)
if not body:
body = u"\n"
if debianbts.SYSTEMS[system].get('query-dpkg', True):
debinfo += get_debian_release_info()
debarch = get_arch()
if debarch:
if utsmachine == debarch:
debinfo += u'Architecture: %s\n' % (debarch)
else:
debinfo += u'Architecture: %s (%s)\n' % (debarch, utsmachine)
else:
debinfo += u'Architecture: ? (%s)\n' % utsmachine
# Gather system info only for bugs not wnpp
if package not in ('wnpp'):
debinfo += u'\n'
if un[0] == 'GNU':
# Use uname -v on Hurd
uname_string = un[3]
else:
kern = un[0]
if kern.startswith('GNU/'):
kern = kern[4:]
uname_string = '%s %s' % (kern, un[2])
if kern == 'Linux':
kinfo = []
if 'SMP' in un[3]:
cores = get_cpu_cores()
if cores > 1:
kinfo += ['SMP w/%d CPU cores' % cores]
else:
kinfo += ['SMP w/1 CPU core']
if 'PREEMPT' in un[3]:
kinfo += ['PREEMPT']
if kinfo:
uname_string = '%s (%s)' % (uname_string, '; '.join(kinfo))
if uname_string:
debinfo += u'Kernel: %s\n' % uname_string
if locinfo:
debinfo += u'Locale: %s\n' % locinfo
if shellpath != '/bin/sh':
debinfo += u'Shell: /bin/sh linked to %s\n' % shellpath
return u"""%s%s%s
-- System Information:
%s%s%s""" % (report, body, incfiles, debinfo, depinfo, confinfo)
# For now...
import bugreport
sysinfo = (package not in ('wnpp', 'ftp.debian.org'))
rep = bugreport.bugreport(package, version=pkgversion, severity=severity,
justification=justification, filename=foundfile,
mode=mode, subject=subject, tags=tags, body=body,
pseudoheaders=pseudos, exinfo=exinfo, type=type,
system=system, depinfo=depinfo, sysinfo=sysinfo,
confinfo=confinfo, incfiles=incfiles)
return unicode(rep)
def get_cpu_cores():
cpucount = 0

Loading…
Cancel
Save