Merge lp:~gz/pyjuju/old_twisted_1029070 into lp:pyjuju
Proposed by
Martin Packman
Status: | Merged |
---|---|
Approved by: | Jim Baker |
Approved revision: | 575 |
Merged at revision: | 575 |
Proposed branch: | lp:~gz/pyjuju/old_twisted_1029070 |
Merge into: | lp:pyjuju |
Diff against target: |
105 lines (+16/-13) 3 files modified
juju/providers/openstack/client.py (+10/-7) juju/providers/openstack/provider.py (+5/-4) juju/providers/openstack/tests/test_client.py (+1/-2) |
To merge this branch: | bzr merge lp:~gz/pyjuju/old_twisted_1029070 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+122849@code.launchpad.net |
Description of the change
Tolerate older twisted versions in openstack provider
The juju ppa includes newer versions of txaws and txzookeeper, but uses
the system twisted version. This means it ftbfs on natty and oneiric,
which doesn't matter much as most devs should be using something newer
anyway, but is not hard to fix. This branch uses some existing compat
code and adds a conditional import, which is enough to make happiness.
To post a comment you must log in.
Reviewers: mp+122849_ code.launchpad. net,
Message:
Please take a look.
Description:
Tolerate older twisted versions in openstack provider
The juju ppa includes newer versions of txaws and txzookeeper, but uses
the system twisted version. This means it ftbfs on natty and oneiric,
which doesn't matter much as most devs should be using something newer
anyway, but is not hard to fix. This branch uses some existing compat
code and adds a conditional import, which is enough to make happiness.
https:/ /code.launchpad .net/~gz/ juju/old_ twisted_ 1029070/ +merge/ 122849
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6496084/
Affected files: openstack/ client. py openstack/ provider. py openstack/ tests/test_ client. py
A [revision details]
M juju/providers/
M juju/providers/
M juju/providers/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/providers/ openstack/ client. py /openstack/ client. py' openstack/ client. py 2012-09-03 11:08:13 +0000 openstack/ client. py 2012-09-05 11:10:08 +0000 internet. interfaces import IProducer
=== modified file 'juju/providers
--- juju/providers/
+++ juju/providers/
@@ -30,10 +30,13 @@
from twisted.
from twisted.internet import reactor
-from twisted.web import ( web._newclient import ResponseFailed web.http_ headers import Headers
- client,
- http_headers,
- )
+from twisted.web.client import Agent
+# Older twisted versions don't expose _newclient exceptions via client
module
+try:
+ from twisted.web.client import ResponseFailed
+except ImportError:
+ from twisted.
+from twisted.
from zope.interface import implements
from juju import errors response_ failed( failure) : ResponseFailed) :
@@ -100,7 +103,7 @@
def _translate_
"""Turn internal twisted client failures into juju exceptions"""
txerr = failure.value
- if isinstance(txerr, client.
+ if isinstance(txerr, ResponseFailed):
for reason in txerr.reasons:
err = reason.value
if isinstance(err, SSLError):
@@ -110,7 +113,7 @@
@inlineCallbacks Headers( {
"User- Agent": [_USER_AGENT],
kwargs[ 'contextFactory '] = WebVerifyingCon textFactory( ) Agent(reactor, **kwargs) method, url, headers, body).addErrback(
_translate_ response_ failed)
def request(method, url, extra_headers=(), body=None, check_certs=False):
- headers = http_headers.
+ headers = Headers({
# GZ 2012-07-03: Previously passed Accept: application/json header
# here, but not always the right thing. Bad for
swift?
@@ -128,7 +131,7 @@
kwargs = {}
if check_certs:
- agent = client.
+ agent = Agent(reactor, **kwargs)
response = yield agent.request(
if response.length == 0:
Index: juju/providers/ openstack/ provider. py /openstack/ provider. py' openstack/ provider. py ...
=== modified file 'juju/providers
--- juju/providers/