[lxc-devel] [pylxd/master] Check for unix socket to set missing scheme
keesbos on Github
lxc-bot at linuxcontainers.org
Sat Dec 17 18:53:58 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161217/962907cc/attachment.bin>
-------------- next part --------------
From 2ed95a33617906a4082d669cfdfb13f710bc4c05 Mon Sep 17 00:00:00 2001
From: Kees Bos <cornelis.bos at gmail.com>
Date: Sat, 17 Dec 2016 19:51:01 +0100
Subject: [PATCH] Check for unix socket to set missing scheme
The os.path.isfile(path) returns False if path is a unix socket
---
pylxd/client.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/pylxd/client.py b/pylxd/client.py
index b4470d0..09868e8 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -14,6 +14,7 @@
import json
import os
import os.path
+import stat
import requests
import requests_unixsocket
@@ -190,7 +191,14 @@ class Client(object):
def __init__(self, endpoint=None, version='1.0', cert=None, verify=True):
self.cert = cert
if endpoint is not None:
- if endpoint.startswith('/') and os.path.isfile(endpoint):
+ if (
+ endpoint.startswith('/') and (
+ os.path.isfile(endpoint) or (
+ os.path.exists(endpoint) and
+ stat.S_ISSOCK(os.stat(endpoint).st_mode)
+ )
+ )
+ ):
self.api = _APINode('http+unix://{}'.format(
parse.quote(endpoint, safe='')))
else:
More information about the lxc-devel
mailing list