From: Ondrej Lichtner <olichtne(a)redhat.com>
Pylint was complaining that None objects are not callable... so I've
replaced the placeholder assignment with a newly added method
not_imported that takes any parameters and raises an exception. In
reality it shouldn't ever get called unless something broken so at least
we'll know now.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/SecureSocket.py | 31 ++++++++++++++++---------------
lnst/Common/Utils.py | 3 +++
lnst/Controller/CtlSecSocket.py | 15 ++++++++-------
lnst/Slave/SlaveSecSocket.py | 15 ++++++++-------
4 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/lnst/Common/SecureSocket.py b/lnst/Common/SecureSocket.py
index cd149c2..b4ee8af 100644
--- a/lnst/Common/SecureSocket.py
+++ b/lnst/Common/SecureSocket.py
@@ -19,6 +19,7 @@ import os
import cPickle
import hashlib
import hmac
+from lnst.Common.Utils import not_imported
DH_GROUP = {"p":
int("0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"\
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD"\
@@ -64,21 +65,21 @@ if SRP_GROUP["p"].bit_length()%8:
class SecSocketException(Exception):
pass
-cryptography = None
-hashes = None
-Cipher = None
-algorithms = None
-modes = None
-padding = None
-ec = None
-EllipticCurvePrivateKey = None
-EllipticCurvePublicKey = None
-RSAPrivateKey = None
-RSAPublicKey = None
-DSAPrivateKey = None
-DSAPublicKey = None
-default_backend = None
-cryptography_imported = False
+cryptography = not_imported
+hashes = not_imported
+Cipher = not_imported
+algorithms = not_imported
+modes = not_imported
+padding = not_imported
+ec = not_imported
+EllipticCurvePrivateKey = not_imported
+EllipticCurvePublicKey = not_imported
+RSAPrivateKey = not_imported
+RSAPublicKey = not_imported
+DSAPrivateKey = not_imported
+DSAPublicKey = not_imported
+default_backend = not_imported
+cryptography_imported = not_imported
def cryptography_imports():
global cryptography_imported
if cryptography_imported:
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 501c81f..d6d6c57 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -307,3 +307,6 @@ class Noop(object):
def noop(*args, **kwargs):
pass
return noop
+
+def not_imported(*args, **kwargs):
+ raise Exception("Object not imported.")
diff --git a/lnst/Controller/CtlSecSocket.py b/lnst/Controller/CtlSecSocket.py
index 34ffb5d..8ffe440 100644
--- a/lnst/Controller/CtlSecSocket.py
+++ b/lnst/Controller/CtlSecSocket.py
@@ -19,13 +19,14 @@ from lnst.Common.SecureSocket import SecureSocket
from lnst.Common.SecureSocket import DH_GROUP, SRP_GROUP
from lnst.Common.SecureSocket import SecSocketException
from lnst.Common.Config import lnst_config
-
-ser = None
-load_pem_private_key = None
-load_pem_public_key = None
-load_ssh_public_key = None
-backend = None
-cryptography_imported = False
+from lnst.Common.Utils import not_imported
+
+ser = not_imported
+load_pem_private_key = not_imported
+load_pem_public_key = not_imported
+load_ssh_public_key = not_imported
+backend = not_imported
+cryptography_imported = not_imported
def cryptography_imports():
global cryptography_imported
if cryptography_imported:
diff --git a/lnst/Slave/SlaveSecSocket.py b/lnst/Slave/SlaveSecSocket.py
index 8810bac..3ba3fef 100644
--- a/lnst/Slave/SlaveSecSocket.py
+++ b/lnst/Slave/SlaveSecSocket.py
@@ -19,13 +19,14 @@ import logging
from lnst.Common.SecureSocket import SecureSocket
from lnst.Common.SecureSocket import DH_GROUP, SRP_GROUP
from lnst.Common.SecureSocket import SecSocketException
-
-ser = None
-load_pem_private_key = None
-load_pem_public_key = None
-load_ssh_public_key = None
-backend = None
-cryptography_imported = False
+from lnst.Common.Utils import not_imported
+
+ser = not_imported
+load_pem_private_key = not_imported
+load_pem_public_key = not_imported
+load_ssh_public_key = not_imported
+backend = not_imported
+cryptography_imported = not_imported
def cryptography_imports():
global cryptography_imported
if cryptography_imported:
--
2.7.2