[lxc-devel] [pylxd/master] Python3 fixes
stgraber on Github
lxc-bot at linuxcontainers.org
Sat Apr 23 05:59:29 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 632 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160423/b29da28b/attachment.bin>
-------------- next part --------------
From e0c1fef8f3e05c68bb780f831063c9c92b4f51fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 23 Apr 2016 07:56:24 +0200
Subject: [PATCH 1/2] python3: Fix use of urllib quote
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
pylxd/client.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pylxd/client.py b/pylxd/client.py
index 33a0e3d..0ca0331 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -13,7 +13,11 @@
# under the License.
import functools
import os
-import urllib
+
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib import quote
import requests
import requests_unixsocket
@@ -115,7 +119,7 @@ def __init__(self, endpoint=None, version='1.0'):
else:
path = '/var/lib/lxd/unix.socket'
self.api = _APINode('http+unix://{}'.format(
- urllib.quote(path, safe='')))
+ quote(path, safe='')))
self.api = self.api[version]
self.containers = self.Containers(self)
From 6fb20e1ba903e0fc2d8df2546b17f89d7669eef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 23 Apr 2016 07:56:34 +0200
Subject: [PATCH 2/2] python3: Fix use of iteritems
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
pylxd/container.py | 6 +++---
pylxd/containerState.py | 2 +-
pylxd/image.py | 2 +-
pylxd/operation.py | 2 +-
pylxd/profile.py | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/pylxd/container.py b/pylxd/container.py
index 6f99a5b..ac12f72 100644
--- a/pylxd/container.py
+++ b/pylxd/container.py
@@ -70,7 +70,7 @@ def create(cls, client, config, wait=False):
def __init__(self, **kwargs):
super(Container, self).__init__()
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
setattr(self, key, value)
def reload(self):
@@ -79,7 +79,7 @@ def reload(self):
if response.status_code == 404:
raise NameError(
'Container named "{}" has gone away'.format(self.name))
- for key, value in response.json()['metadata'].iteritems():
+ for key, value in response.json()['metadata'].items():
setattr(self, key, value)
def update(self, wait=False):
@@ -124,7 +124,7 @@ def _set_state(self, state, timeout=30, force=True, wait=False):
def state(self):
state = ContainerState()
response = self._client.api.containers[self.name].state.get()
- for key, value in response.json()['metadata'].iteritems():
+ for key, value in response.json()['metadata'].items():
setattr(state, key, value)
return state
diff --git a/pylxd/containerState.py b/pylxd/containerState.py
index 80a91f9..354417f 100644
--- a/pylxd/containerState.py
+++ b/pylxd/containerState.py
@@ -16,5 +16,5 @@
class ContainerState():
def __init__(self, **kwargs):
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
setattr(self, key, value)
diff --git a/pylxd/image.py b/pylxd/image.py
index 31a5257..56fbf13 100644
--- a/pylxd/image.py
+++ b/pylxd/image.py
@@ -65,7 +65,7 @@ def create(cls, client, image_data, public=False, wait=False):
def __init__(self, **kwargs):
super(Image, self).__init__()
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
setattr(self, key, value)
def update(self):
diff --git a/pylxd/operation.py b/pylxd/operation.py
index b5c7d67..2bbd613 100644
--- a/pylxd/operation.py
+++ b/pylxd/operation.py
@@ -37,7 +37,7 @@ def get(cls, client, operation_id):
def __init__(self, **kwargs):
super(Operation, self).__init__()
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
setattr(self, key, value)
def wait(self):
diff --git a/pylxd/profile.py b/pylxd/profile.py
index 13c3847..b0784c2 100644
--- a/pylxd/profile.py
+++ b/pylxd/profile.py
@@ -54,7 +54,7 @@ def create(cls, client, name, config):
def __init__(self, **kwargs):
super(Profile, self).__init__()
- for key, value in kwargs.iteritems():
+ for key, value in kwargs.items():
setattr(self, key, value)
def update(self):
More information about the lxc-devel
mailing list