core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, and https://review.gluster.org/#/c/19952/ This patch adds version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: Fedora packaging guidelines require explicit shebangs, so popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, and zip have already been applied. Note: these 2to3 fixes report no changes are necessary: exec, execfile, exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: I8d393064a1837874d8b4bc87c8ce05c679664642 updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
This commit is contained in:
parent
3894f4262d
commit
7cdcd9b022
@ -13,7 +13,10 @@
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import signal
|
||||
import SocketServer
|
||||
try:
|
||||
import socketserver
|
||||
except ImportError:
|
||||
import SocketServer as socketserver
|
||||
import socket
|
||||
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||
|
||||
|
@ -16,7 +16,10 @@ import fcntl
|
||||
from errno import EBADF
|
||||
from threading import Thread
|
||||
import multiprocessing
|
||||
from Queue import Queue
|
||||
try:
|
||||
from queue import Queue
|
||||
except ImportError:
|
||||
from Queue import Queue
|
||||
from datetime import datetime, timedelta
|
||||
import base64
|
||||
import hmac
|
||||
|
@ -1,3 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
|
||||
# This file is part of GlusterFS.
|
||||
#
|
||||
# This file is licensed to you under your choice of the GNU Lesser
|
||||
# General Public License, version 3 or any later version (LGPLv3 or
|
||||
# later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
# cases as published by the Free Software Foundation.
|
||||
#
|
||||
# Converts old style args into new style args
|
||||
|
||||
from __future__ import print_function
|
||||
|
@ -1,4 +1,15 @@
|
||||
#!/usr/bin/python2
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
|
||||
# This file is part of GlusterFS.
|
||||
#
|
||||
# This file is licensed to you under your choice of the GNU Lesser
|
||||
# General Public License, version 3 or any later version (LGPLv3 or
|
||||
# later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
# cases as published by the Free Software Foundation.
|
||||
#
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import time
|
||||
import os
|
||||
|
@ -1,4 +1,18 @@
|
||||
from ConfigParser import ConfigParser, NoSectionError
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
|
||||
# This file is part of GlusterFS.
|
||||
#
|
||||
# This file is licensed to you under your choice of the GNU Lesser
|
||||
# General Public License, version 3 or any later version (LGPLv3 or
|
||||
# later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
# cases as published by the Free Software Foundation.
|
||||
#
|
||||
|
||||
try:
|
||||
from configparser import ConfigParser, NoSectionError
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser, NoSectionError
|
||||
import os
|
||||
from string import Template
|
||||
from datetime import datetime
|
||||
|
@ -13,7 +13,10 @@ from __future__ import print_function
|
||||
import fcntl
|
||||
import os
|
||||
import tempfile
|
||||
import urllib
|
||||
try:
|
||||
import urllib.parse as urllib
|
||||
except ImportError:
|
||||
import urllib
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
@ -1,3 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
|
||||
# This file is part of GlusterFS.
|
||||
#
|
||||
# This file is licensed to you under your choice of the GNU Lesser
|
||||
# General Public License, version 3 or any later version (LGPLv3 or
|
||||
# later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
# cases as published by the Free Software Foundation.
|
||||
#
|
||||
|
||||
import logging
|
||||
from logging import Logger, handlers
|
||||
import sys
|
||||
|
@ -13,9 +13,18 @@ import sys
|
||||
import time
|
||||
import logging
|
||||
from threading import Condition
|
||||
import thread
|
||||
from Queue import Queue
|
||||
import cPickle as pickle
|
||||
try:
|
||||
import _thread
|
||||
except ImportError:
|
||||
import thread as _thread
|
||||
try:
|
||||
from queue import Queue
|
||||
except ImportError:
|
||||
from Queue import Queue
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
from syncdutils import Thread, select, lf
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
|
||||
# This file is part of GlusterFS.
|
||||
#
|
||||
# This file is licensed to you under your choice of the GNU Lesser
|
||||
# General Public License, version 3 or any later version (LGPLv3 or
|
||||
# later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
# cases as published by the Free Software Foundation.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
from syncdutils import lf
|
||||
|
@ -28,7 +28,10 @@ import select as oselect
|
||||
from os import waitpid as owaitpid
|
||||
import xml.etree.ElementTree as XET
|
||||
from select import error as SelectError
|
||||
from cPickle import PickleError
|
||||
try:
|
||||
from cPickle import PickleError
|
||||
except ImportError:
|
||||
from pickle import PickleError
|
||||
|
||||
from conf import GLUSTERFS_LIBEXECDIR, UUID_FILE
|
||||
sys.path.insert(1, GLUSTERFS_LIBEXECDIR)
|
||||
|
@ -13,7 +13,10 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
try:
|
||||
import urllib.parse as urllib
|
||||
except ImportError:
|
||||
import urllib
|
||||
import time
|
||||
|
||||
from utils import mkdirp, setup_logger, create_file, output_write, find
|
||||
|
@ -16,7 +16,10 @@ import xattr
|
||||
import logging
|
||||
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||
import hashlib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
try:
|
||||
import urllib.parse as urllib
|
||||
except ImportError:
|
||||
import urllib
|
||||
import codecs
|
||||
|
||||
import libgfchangelog
|
||||
|
@ -9,7 +9,10 @@
|
||||
# cases as published by the Free Software Foundation.
|
||||
|
||||
import os
|
||||
import ConfigParser
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
|
@ -14,7 +14,10 @@ import sys
|
||||
import os
|
||||
import logging
|
||||
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
try:
|
||||
import urllib.parse as urllib
|
||||
except ImportError:
|
||||
import urllib
|
||||
from errno import ENOTEMPTY
|
||||
|
||||
from utils import setup_logger, mkdirp, handle_rm_error
|
||||
|
Loading…
x
Reference in New Issue
Block a user