[Reportbug-commits] r634 - in branches/manual_merge/reportbug (15 files)

morph-guest at users.alioth.debian.org morph-guest at users.alioth.debian.org
Sat Aug 16 23:46:02 UTC 2008


    Date: Saturday, August 16, 2008 @ 23:46:01
  Author: morph-guest
Revision: 634

cherry picking reportbug/ dir

Added:
  branches/manual_merge/reportbug/bugreport.py
  branches/manual_merge/reportbug/ui/__init__.py
Modified:
  branches/manual_merge/reportbug/__init__.py
  branches/manual_merge/reportbug/checkbuildd.py
  branches/manual_merge/reportbug/checkversions.py
  branches/manual_merge/reportbug/debianbts.py
  branches/manual_merge/reportbug/exceptions.py
  branches/manual_merge/reportbug/hiermatch.py
  branches/manual_merge/reportbug/submit.py
  branches/manual_merge/reportbug/tempfiles.py
  branches/manual_merge/reportbug/ui/newt.py
  branches/manual_merge/reportbug/ui/text.py
  branches/manual_merge/reportbug/ui/urwid.py
  branches/manual_merge/reportbug/urlutils.py
  branches/manual_merge/reportbug/utils.py

Modified: branches/manual_merge/reportbug/__init__.py
===================================================================
--- branches/manual_merge/reportbug/__init__.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/__init__.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+# -*- python -*-
+# reportbug - Report a bug in the Debian distribution.
+#   Written by Chris Lawrence <lawrencc at 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 at debian.org>'

Added: branches/manual_merge/reportbug/bugreport.py
===================================================================
--- branches/manual_merge/reportbug/bugreport.py	                        (rev 0)
+++ branches/manual_merge/reportbug/bugreport.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -0,0 +1,173 @@
+#
+# bugreport module - object containing bug stuff for reporting
+#   Written by Chris Lawrence <lawrencc at 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)

Modified: branches/manual_merge/reportbug/checkbuildd.py
===================================================================
--- branches/manual_merge/reportbug/checkbuildd.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/checkbuildd.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -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 at 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 commands
 
 from urlutils import open_url
-from reportbug_exceptions import (
+from reportbug.exceptions import (
     NoNetwork,
     )
 

Modified: branches/manual_merge/reportbug/checkversions.py
===================================================================
--- branches/manual_merge/reportbug/checkversions.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/checkversions.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -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 at 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 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 @@
     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)

Modified: branches/manual_merge/reportbug/debianbts.py
===================================================================
--- branches/manual_merge/reportbug/debianbts.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/debianbts.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -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 at 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 textwrap
 import pprint
 
-import reportbug
 import checkversions
-from reportbug_exceptions import (
+from exceptions import (
     NoNetwork,
     )
 from urlutils import open_url
@@ -245,14 +244,14 @@
             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 @@
     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 @@
         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 @@
 
     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 @@
               '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 at progeny.com',
-              'type' : 'gnats', 'otherpkgs' : progenyother },
+              'cgiroot' : 'http://bugs.debian.org/cgi-bin/',
+              'infofunc' : debian_infofunc,
+              },
             'ubuntu' :
             { 'name' : 'Ubuntu', 'email' : 'ubuntu-users at lists.ubuntu.com',
-              'type' : 'mailto' },
+              'type' : 'mailto',
+              'infofunc' : ubuntu_infofunc,
+              },
             'guug' :
             { 'name' : 'GUUG (German Unix User Group)',
               'email' : '%s at bugs.guug.de', 'query-dpkg' : False },

Modified: branches/manual_merge/reportbug/exceptions.py
===================================================================
--- branches/manual_merge/reportbug/exceptions.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/exceptions.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,4 +1,3 @@
-# reportbuglib/reportbug_exceptions.py
 # Exceptions for reportbug
 #   Written by Chris Lawrence <lawrencc at debian.org>
 #   (C) 2002-04 Chris Lawrence

Modified: branches/manual_merge/reportbug/hiermatch.py
===================================================================
--- branches/manual_merge/reportbug/hiermatch.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/hiermatch.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,9 +1,8 @@
 # Doing match on a list of string or a hierarchy.
 
 import re
+import exceptions
 
-from reportbuglib import reportbug_exceptions
-
 def egrep_list(strlist, pattern_str, subindex=None):
     """Use the pattern_str to find any match in a list of strings."""
     """Return: a list of index for the matchs into the origin list."""
@@ -14,8 +13,8 @@
     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))

Modified: branches/manual_merge/reportbug/submit.py
===================================================================
--- branches/manual_merge/reportbug/submit.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/submit.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,4 +1,4 @@
-# reportbuglib/reportbug_submit module - email and GnuPG functions
+# reportbug_submit module - email and GnuPG functions
 #   Written by Chris Lawrence <lawrencc at debian.org>
 #   Copyright (C) 1999-2006 Chris Lawrence
 #
@@ -39,18 +39,13 @@
 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
 

Modified: branches/manual_merge/reportbug/tempfiles.py
===================================================================
--- branches/manual_merge/reportbug/tempfiles.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/tempfiles.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,7 +1,7 @@
 #
-# reportbuglib/rbtempfile module - Temporary file handling for reportbug
+# tempfiles module - Temporary file handling for reportbug
 #   Written by Chris Lawrence <lawrencc at debian.org>
-#   (C) 1999-2004 Chris Lawrence
+#   (C) 1999-2008 Chris Lawrence
 #
 # This program is freely distributable per the following license:
 #

Added: branches/manual_merge/reportbug/ui/__init__.py
===================================================================
--- branches/manual_merge/reportbug/ui/__init__.py	                        (rev 0)
+++ branches/manual_merge/reportbug/ui/__init__.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -0,0 +1,25 @@
+#!/usr/bin/python -S
+# -*- python -*-
+# reportbug - Report a bug in the Debian distribution.
+#   Written by Chris Lawrence <lawrencc at 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']

Modified: branches/manual_merge/reportbug/ui/newt.py
===================================================================
--- branches/manual_merge/reportbug/ui/newt.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/ui/newt.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -23,7 +23,6 @@
 import sys
 import commands
 import string
-
 import debianbts
 from reportbug_exceptions import (
     UINotImportable,

Modified: branches/manual_merge/reportbug/ui/text.py
===================================================================
--- branches/manual_merge/reportbug/ui/text.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/ui/text.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,7 +1,6 @@
-# reportbuglib/reportbug_ui_text.py
 # Text user interface for reportbug
 #   Written by Chris Lawrence <lawrencc at 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 @@
 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 @@
     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 = ''

Modified: branches/manual_merge/reportbug/ui/urwid.py
===================================================================
--- branches/manual_merge/reportbug/ui/urwid.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/ui/urwid.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -1,7 +1,6 @@
-# reportbuglib/reportbug_ui_urwid.py
 # urwid user interface for reportbug
 #   Written by Chris Lawrence <lawrencc at 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 @@
     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 @@
     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 @@
 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 @@
     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 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_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 @@
         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()

Modified: branches/manual_merge/reportbug/urlutils.py
===================================================================
--- branches/manual_merge/reportbug/urlutils.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/urlutils.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -2,7 +2,7 @@
 # urlutils.py - Simplified urllib handling
 #
 #   Written by Chris Lawrence <lawrencc at debian.org>
-#   (C) 1999-2006 Chris Lawrence
+#   (C) 1999-2008 Chris Lawrence
 #
 # This program is freely distributable per the following license:
 #
@@ -33,12 +33,14 @@
 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"
     #print page.info().headers

Modified: branches/manual_merge/reportbug/utils.py
===================================================================
--- branches/manual_merge/reportbug/utils.py	2008-08-16 23:25:49 UTC (rev 633)
+++ branches/manual_merge/reportbug/utils.py	2008-08-16 23:46:01 UTC (rev 634)
@@ -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 at 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 at debian.org>'
-
 import sys
 import os
 import re
@@ -38,9 +32,10 @@
 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,15 +46,20 @@
 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',
        'gnome2': 'A graphical (Gnome 2) interface'}
@@ -688,6 +688,9 @@
 
     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,138 +706,19 @@
                           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')
+    # For now...
+    import bugreport
 
-    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"))
+    sysinfo = (package not in ('wnpp', 'ftp.debian.org'))
 
-            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))
+    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)
 
-    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)
-
 def get_cpu_cores():
     cpucount = 0
     fob = open('/proc/cpuinfo')




More information about the Reportbug-commits mailing list