You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/04/23 05:13:35 UTC
[1/3] libcloud git commit: azure_blobs.py: Apply lxml ElementTree
import pattern properly
Repository: libcloud
Updated Branches:
refs/heads/trunk e6a6676a5 -> 0789cb58d
azure_blobs.py: Apply lxml ElementTree import pattern properly
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1588cc73
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1588cc73
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1588cc73
Branch: refs/heads/trunk
Commit: 1588cc738ce472c329f1bba81bdef5ca977e9d64
Parents: 3a20e92
Author: Peter Schmidt <pe...@peterjs.com>
Authored: Fri Apr 22 22:45:31 2016 +1000
Committer: anthony-shaw <an...@apache.org>
Committed: Sat Apr 23 13:13:17 2016 +1000
----------------------------------------------------------------------
libcloud/storage/drivers/azure_blobs.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1588cc73/libcloud/storage/drivers/azure_blobs.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/azure_blobs.py b/libcloud/storage/drivers/azure_blobs.py
index 13d42f6..4e10df6 100644
--- a/libcloud/storage/drivers/azure_blobs.py
+++ b/libcloud/storage/drivers/azure_blobs.py
@@ -19,7 +19,10 @@ import base64
import os
import binascii
-from xml.etree.ElementTree import Element, SubElement
+try:
+ from lxml import etree as ET
+except ImportError:
+ from xml.etree import ElementTree as ET
from libcloud.utils.py3 import PY3
from libcloud.utils.py3 import httplib
@@ -693,10 +696,10 @@ class AzureBlobsStorageDriver(StorageDriver):
:type upload_id: ``list``
"""
- root = Element('BlockList')
+ root = ET.Element('BlockList')
for block_id in chunks:
- part = SubElement(root, 'Uncommitted')
+ part = ET.SubElement(root, 'Uncommitted')
part.text = str(block_id)
data = tostring(root)
[2/3] libcloud git commit: abiquo.py: Apply lxml ElementTree import
pattern properly
Posted by an...@apache.org.
abiquo.py: Apply lxml ElementTree import pattern properly
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3a20e92c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3a20e92c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3a20e92c
Branch: refs/heads/trunk
Commit: 3a20e92cab01a7c6634067e589e980fd99dfe87f
Parents: e6a6676
Author: Peter Schmidt <pe...@peterjs.com>
Authored: Fri Apr 22 22:00:44 2016 +1000
Committer: anthony-shaw <an...@apache.org>
Committed: Sat Apr 23 13:13:17 2016 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/abiquo.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/3a20e92c/libcloud/compute/drivers/abiquo.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/abiquo.py b/libcloud/compute/drivers/abiquo.py
index fdcc59d..12097f3 100644
--- a/libcloud/compute/drivers/abiquo.py
+++ b/libcloud/compute/drivers/abiquo.py
@@ -20,7 +20,10 @@ This version is compatible with the following versions of Abiquo:
* Abiquo 3.1 (http://wiki.abiquo.com/display/ABI31/The+Abiquo+API)
"""
-import xml.etree.ElementTree as ET
+try:
+ from lxml import etree as ET
+except ImportError:
+ from xml.etree import ElementTree as ET
from libcloud.compute.base import NodeDriver, NodeSize
from libcloud.compute.types import Provider, LibcloudError
[3/3] libcloud git commit: profitbricks.py: Figure out a pattern that
works with xml + lxml Closes #772
Posted by an...@apache.org.
profitbricks.py: Figure out a pattern that works with xml + lxml Closes #772
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/0789cb58
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0789cb58
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0789cb58
Branch: refs/heads/trunk
Commit: 0789cb58d2d293b984696da0c1f674311248485b
Parents: 1588cc7
Author: Peter Schmidt <pe...@peterjs.com>
Authored: Fri Apr 22 23:11:53 2016 +1000
Committer: anthony-shaw <an...@apache.org>
Committed: Sat Apr 23 13:13:18 2016 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/profitbricks.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/0789cb58/libcloud/compute/drivers/profitbricks.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/profitbricks.py b/libcloud/compute/drivers/profitbricks.py
index 697b082..ab217f0 100644
--- a/libcloud/compute/drivers/profitbricks.py
+++ b/libcloud/compute/drivers/profitbricks.py
@@ -85,6 +85,16 @@ class ProfitBricksConnection(ConnectionUserAndKey):
api_prefix = API_VERSION
responseCls = ProfitBricksResponse
+ # Supporting xml + lxml is funky :S
+ SOAPENV_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/'
+ SOAPENV = '{%s}' % SOAPENV_NAMESPACE
+ WS_NAMESPACE = 'http://ws.api.profitbricks.com/'
+ WS = '{%s}' % WS_NAMESPACE
+ NSMAP = {
+ 'soapenv': SOAPENV_NAMESPACE,
+ 'ws': WS_NAMESPACE,
+ }
+
def add_default_headers(self, headers):
headers['Content-Type'] = 'text/xml'
headers['Authorization'] = 'Basic %s' % (base64.b64encode(
@@ -93,13 +103,11 @@ class ProfitBricksConnection(ConnectionUserAndKey):
return headers
def encode_data(self, data):
- soap_env = ET.Element('soapenv:Envelope', {
- 'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
- 'xmlns:ws': 'http://ws.api.profitbricks.com/'
- })
- ET.SubElement(soap_env, 'soapenv:Header')
- soap_body = ET.SubElement(soap_env, 'soapenv:Body')
- soap_req_body = ET.SubElement(soap_body, 'ws:%s' % (data['action']))
+ soap_env = ET.Element(self.SOAPENV + 'Envelope',
+ self.NSMAP, **self.NSMAP)
+ ET.SubElement(soap_env, self.SOAPENV + 'Header')
+ soap_body = ET.SubElement(soap_env, self.SOAPENV + 'Body')
+ soap_req_body = ET.SubElement(soap_body, self.WS + data['action'])
if 'request' in data.keys():
soap_req_body = ET.SubElement(soap_req_body, 'request')