arsenal-devel team mailing list archive
-
arsenal-devel team
-
Mailing list archive
-
Message #00096
Bug properties
Bugs that are filed by or appended to by apport have key:value pairs
inserted into their descriptions. The patch below enables arsenal to
parse this data out and provides it in a dictionary structure.
Posting to the list for comment before I merge it.
Also, attaching an example script for testing purposes, which outputs
the bug properties in JSON format.
Comments welcomed.
Bryce
=== modified file 'lpltk/bug.py'
--- a/lpltk/bug.py 2010-07-17 18:19:25 +0000
+++ b/lpltk/bug.py 2010-12-07 08:09:09 +0000
@@ -1,5 +1,6 @@
#!/usr/bin/python
+import re
from utils import o2str
from tags import BugTags
from attachments import Attachments
@@ -27,6 +28,7 @@
self.__tags = None
self.__attachments = None
self.__owner = None
+ self.__properties = None
#--------------------------------------------------------------------------
# title
@@ -89,4 +91,42 @@
def attachments(self):
return Attachments(self)
+ def _parse_properties(self, text):
+ return props
+
+ #--------------------------------------------------------------------------
+ # properties
+ #
+ @property
+ def properties(self):
+ '''Returns dict of key: value pairs found in the bug description
+
+ This parses the bug report description into a more
+ programmatically digestable dictionary form.
+ '''
+ if self.__properties is None:
+ re_kvp = re.compile("^(\s*)([\.\-\w]+):\s*(.*)$")
+ re_error = re.compile("^Error:\s*(.*)$")
+ self.__properties = {}
+ last_key = {'': 'bar'}
+ for line in self.description.split("\n"):
+ m = re_kvp.match(line)
+ if not m:
+ continue
+
+ level = m.group(1)
+ item = m.group(2)
+ value = m.group(3)
+ key = item
+
+ if len(level) > 0:
+ key = "%s.%s" %(last_key[''], item)
+ last_key[level] = item
+
+ m = re_error.match(value)
+ if not m:
+ self.__properties[key] = value
+
+ return self.__properties
+
# vi:set ts=4 sw=4 expandtab:
#!/usr/bin/env python
import sys
import simplejson as json
from lpltk import LaunchpadService
from lpltk.bug import Bug
lp = LaunchpadService()
if len(sys.argv) < 2:
print "Usage: similar-bugs [bug-id]"
sys.exit(2)
bug_id = sys.argv[1]
bug = Bug(lp.launchpad, bug_id)
print json.dumps(bug.properties, indent=4)
{
"dmi.board.vendor": "To be filled by O.E.M.",
"PackageArchitecture": "all",
"dmi.bios.version": "V1.0K",
"dmi.product.version": "REV:1.0",
"SourcePackage": "jockey",
"dmi.chassis.asset.tag": "To Be Filled By O.E.M.",
"ProcVersionSignature": "Ubuntu 2.6.32-21.32-generic 2.6.32.11+drm33.2",
"ProcEnviron": "",
"dmi.board.version": "To be filled by O.E.M.",
"dmi.bios.vendor": "American Megatrends Inc.",
"dmi.board.name": "To be filled by O.E.M.",
"Date": "Fri Apr 30 15:13:29 2010",
"dmi.chassis.vendor": "To Be Filled By O.E.M.",
"ProcCmdLine": "BOOT_IMAGE=/boot/vmlinuz-2.6.32-21-generic root=UUID=b3f7549e-bb89-4287-b973-2fb111477470 ro quiet splash",
"dmi.chassis.type": "3",
"Package": "jockey-gtk 0.5.8-0ubuntu8",
"ProblemType": "Bug",
"dmi.product.name": "MS-163A",
".var.log.jockey.log": "2010-04-30 11:38:01,940 DEBUG: Updating repository indexes...",
"Architecture": "amd64",
"ERROR": "dbus.proxies:Introspect error on :1.52:/DeviceDriver: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.",
"dbus.exceptions.DBusException": "org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.",
"InstallationMedia": "Ubuntu 10.04 LTS \"Lucid Lynx\" - Release amd64 (20100429)",
"dmi.modalias": "dmi:bvnAmericanMegatrendsInc.:bvrV1.0K:bd09/26/2007:svnMICRO-STARINTERNATIONALCO.,LTD:pnMS-163A:pvrREV1.0:rvnTobefilledbyO.E.M.:rnTobefilledbyO.E.M.:rvrTobefilledbyO.E.M.:cvnToBeFilledByO.E.M.:ct3:cvrToBeFilledByO.E.M.:",
"MachineType": "MICRO-STAR INTERNATIONAL CO., LTD MS-163A",
"dmi.chassis.version": "To Be Filled By O.E.M.",
"dmi.bios.date": "09/26/2007",
"Uname": "Linux 2.6.32-21-generic x86_64",
"dmi.board.asset.tag": "To be filled by O.E.M.",
"DistroRelease": "Ubuntu 10.04",
"dmi.sys.vendor": "MICRO-STAR INTERNATIONAL CO., LTD"
}
Follow ups