Commit fc3169ee authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Remove python2 support

Remove also old init version
parent 510deb64
......@@ -37,7 +37,6 @@ setup(
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
......@@ -46,7 +45,7 @@ setup(
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
python_requires=">=2.7",
python_requires=">=3.7",
entry_points={
'console_scripts': [
'generate-signature-key = slapos.signature:run',
......
......@@ -27,19 +27,12 @@ import tarfile
import tempfile
import traceback
from base64 import b64encode, b64decode
try:
from configparser import ConfigParser
from http.client import HTTPConnection, HTTPSConnection
from urllib.error import HTTPError
from urllib.parse import urlsplit
from urllib.request import urlopen
basestring = bytes, str
except ImportError:
from ConfigParser import SafeConfigParser as ConfigParser
ConfigParser.read_file = ConfigParser.readfp
from httplib import HTTPConnection, HTTPSConnection
from urllib2 import HTTPError, urlopen
from urlparse import urlsplit
from configparser import ConfigParser
from http.client import HTTPConnection, HTTPSConnection
from urllib.error import HTTPError
from urllib.parse import urlsplit
from urllib.request import urlopen
basestring = bytes, str
try:
from OpenSSL import crypto
except ImportError:
......@@ -171,32 +164,8 @@ class NetworkcacheClient(object):
'''
signature_private_key = None
def __init__(self, *args, **kw):
def __init__(self, config, signature_certificate_list=None):
"""Initializes shacache object"""
if isinstance(args[0], basestring) if args else 'config' not in kw:
self.__old_init(*args, **kw) # BBB
else:
self.__new_init(*args, **kw)
def __old_init(self, shacache, shadir, signature_private_key_file=None,
signature_certificate_list=None, shacache_ca_file=None,
shacache_key_file=None, shacache_cert_file=None,
shadir_ca_file=None, shadir_key_file=None, shadir_cert_file=None):
self.__new_init({
'signature-private-key-file': signature_private_key_file,
'download-cache-url': shacache,
'upload-cache-url': shacache,
'shacache-ca-file': shacache_ca_file,
'shacache-cert-file': shacache_cert_file,
'shacache-key-file': shacache_key_file,
'download-dir-url': shadir,
'upload-dir-url': shadir,
'shadir-ca-file': shadir_ca_file,
'shadir-cert-file': shadir_cert_file,
'shadir-key-file': shadir_key_file,
}, signature_certificate_list)
def __new_init(self, config, signature_certificate_list=None):
if not hasattr(config, 'get'):
parser = ConfigParser()
parser.read_file(config)
......
......@@ -18,14 +18,9 @@ import slapos.libnetworkcache
import slapos.signature
import sys
from io import BytesIO
try:
from http.server import BaseHTTPRequestHandler, HTTPServer
from http.client import HTTPConnection, NOT_FOUND
from urllib.error import HTTPError
except ImportError:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from httplib import HTTPConnection, NOT_FOUND
from urllib2 import HTTPError
from http.server import BaseHTTPRequestHandler, HTTPServer
from http.client import HTTPConnection, NOT_FOUND
from urllib.error import HTTPError
logging.basicConfig()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment