← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~lifeless/python-oops/hostname into lp:python-oops

 

Robert Collins has proposed merging lp:~lifeless/python-oops/hostname into lp:python-oops.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lifeless/python-oops/hostname/+merge/78053

Cut a release, improve docs a little and add support for nabbing the hostname (on by default)
-- 
https://code.launchpad.net/~lifeless/python-oops/hostname/+merge/78053
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-oops/hostname into lp:python-oops.
=== added file 'MANIFEST.in'
=== modified file 'NEWS'
--- NEWS	2011-09-18 22:36:02 +0000
+++ NEWS	2011-10-04 07:15:29 +0000
@@ -6,10 +6,16 @@
 NEXT
 ----
 
+0.0.8
+-----
+
+* Attach the local hostname to reports by default. This permits differentiating
+  different hosts in a cluster of the same reporters.  (Robert Collins)
+
 0.0.7
 -----
 
-Add well known key 'timeline' as a location for the 'sequence of things that
-led up to the OOPS'. See also the oops-timeline module which will populate this
-from a Timeline object.
+* Add well known key 'timeline' as a location for the 'sequence of things that
+  led up to the OOPS'. See also the oops-timeline module which will populate this
+  from a Timeline object.
 

=== modified file 'oops/__init__.py'
--- oops/__init__.py	2011-09-18 22:36:02 +0000
+++ oops/__init__.py	2011-10-04 07:15:29 +0000
@@ -25,7 +25,7 @@
 # established at this point, and setup.py will use a version of next-$(revno).
 # If the releaselevel is 'final', then the tarball will be major.minor.micro.
 # Otherwise it is major.minor.micro~$(revno).
-__version__ = (0, 0, 7, 'beta', 0)
+__version__ = (0, 0, 8, 'beta', 0)
 
 __all__ = [
     'Config'

=== modified file 'oops/config.py'
--- oops/config.py	2011-10-02 23:27:35 +0000
+++ oops/config.py	2011-10-04 07:15:29 +0000
@@ -26,6 +26,11 @@
   ...    return 'id 1'
   >>> config.publishers.append(demo_publish)
 
+  This allows aggregate of oops reports from different programs into one
+  oops-tools install.
+
+  >>> config.template['reporter'] = 'myprogram'
+
 * Create a report::
 
   >>> report = config.create()
@@ -35,7 +40,7 @@
   >>> config.publish(report)
   ['id 1']
   >>> report
-  {'id': 'id 1'}
+  {'id': 'id 1', 'template': 'myprogram'}
 
 * See the Config object pydoc for more information.
 
@@ -52,8 +57,7 @@
 * type: The type of the exception that occurred.
 * value: The value of the exception that occurred.
 * time: The time at which the exception occurred.
-* pageid: The identifier for the template/script that oopsed.
-  [deprecated: This maps to the new topic key instead.]
+* hostname: The hostname of the machine the oops was created on. (Set by default)
 * branch_nick: The branch nickname.
 * revno: The revision number of the branch.
 * tb_text: A text version of the traceback.

=== modified file 'oops/createhooks.py'
--- oops/createhooks.py	2011-08-17 01:07:34 +0000
+++ oops/createhooks.py	2011-10-04 07:15:29 +0000
@@ -23,6 +23,7 @@
 __all__ = [
     'attach_exc_info',
     'attach_date',
+    'attach_hostname',
     'copy_reporter',
     'copy_topic',
     'copy_url',
@@ -33,6 +34,7 @@
 __metaclass__ = type
 
 import datetime
+import socket
 import traceback
 
 from pytz import utc
@@ -113,6 +115,11 @@
     report['tb_text'] = tb_text
 
 
+def attach_hostname(report, context):
+    """Add the machines hostname to report in the 'hostname' key."""
+    report['hostname'] = socket.gethostname()
+
+
 # hooks that are installed into Config objects by default.
 default_hooks = [
     attach_exc_info,
@@ -120,4 +127,5 @@
     copy_reporter,
     copy_topic,
     copy_url,
+    attach_hostname,
     ]

=== modified file 'oops/tests/test_createhooks.py'
--- oops/tests/test_createhooks.py	2011-08-17 01:07:34 +0000
+++ oops/tests/test_createhooks.py	2011-10-04 07:15:29 +0000
@@ -20,6 +20,7 @@
 
 import datetime
 from functools import partial
+import socket
 import sys
 
 import testtools
@@ -28,6 +29,7 @@
 from oops.createhooks import (
     attach_exc_info,
     attach_date,
+    attach_hostname,
     default_hooks,
     copy_reporter,
     copy_topic,
@@ -81,7 +83,7 @@
 
     def test_defaults(self):
         self.assertEqual([attach_exc_info, attach_date, copy_reporter, copy_topic,
-            copy_url], default_hooks)
+            copy_url, attach_hostname], default_hooks)
 
     def test_reporter(self):
         report = {}
@@ -103,3 +105,9 @@
         self.assertEqual({}, report)
         copy_url(report, {'url': 'foo'})
         self.assertEqual({'url':'foo'}, report)
+
+    def test_hostname(self):
+        report = {}
+        attach_hostname(report, {})
+        expected_hostname = socket.gethostname()
+        self.assertEqual({'hostname': expected_hostname}, report)

=== modified file 'setup.py'
--- setup.py	2011-09-18 22:36:02 +0000
+++ setup.py	2011-10-04 07:15:29 +0000
@@ -23,7 +23,7 @@
         os.path.join(os.path.dirname(__file__), 'README'), 'rb').read()
 
 setup(name="oops",
-      version="0.0.7",
+      version="0.0.8",
       description=\
               "OOPS report model and default allocation/[de]serialization.",
       long_description=description,