yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00373
[Merge] lp:~gmb/charms/oneiric/buildbot-master/tests-fixes into lp:~yellow/charms/oneiric/buildbot-master/trunk
Graham Binns has proposed merging lp:~gmb/charms/oneiric/buildbot-master/tests-fixes into lp:~yellow/charms/oneiric/buildbot-master/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~gmb/charms/oneiric/buildbot-master/tests-fixes/+merge/92091
Changes from gmb and frankban 2012-02-08:
=========================================
- Added some tweaks to helpers.py to make testing a bit easier.
--
https://code.launchpad.net/~gmb/charms/oneiric/buildbot-master/tests-fixes/+merge/92091
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~gmb/charms/oneiric/buildbot-master/tests-fixes into lp:~yellow/charms/oneiric/buildbot-master/trunk.
=== modified file 'hooks/helpers.py'
--- hooks/helpers.py 2012-02-07 14:37:13 +0000
+++ hooks/helpers.py 2012-02-08 17:46:18 +0000
@@ -19,9 +19,11 @@
'unit_info',
]
+import base64
import json
import os
import re
+import StringIO
import subprocess
import sys
from textwrap import dedent
@@ -90,13 +92,28 @@
def unit_info(service_name, item_name, data=None):
if data is None:
- data = yaml.safe_load(run('juju', 'status'))
- services = data['services'][service_name]
- units = services['units']
+ output = subprocess.check_output(['juju', 'status'], shell=False)
+ data = yaml.safe_load(output)
+ service = data['services'].get(service_name)
+ if service is None:
+ # XXX 2012-02-08 gmb:
+ # This allows us to cope with the race condition that we
+ # have between deploying a service and having it come up in
+ # `juju status`. We could proably do with cleaning it up so
+ # that it fails a bit more noisily after a while.
+ return ''
+ units = service['units']
item = units.items()[0][1][item_name]
return item
+def encode_file(filename):
+ """base64 encode the contents of a file and return it."""
+ with open(filename) as f:
+ contents = f.read()
+ return base64.encodestring(contents).strip()
+
+
def grep(content, filename):
with open(filename) as f:
for line in f:
Follow ups