mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
use six module to support python 2 and 3 instead of conditional imports
This commit is contained in:
+2
-8
@@ -1,17 +1,11 @@
|
||||
import json
|
||||
import logging
|
||||
import psycopg2
|
||||
import sys
|
||||
|
||||
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
from six.moves.socketserver import ThreadingMixIn
|
||||
from threading import Thread
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from socketserver import ThreadingMixIn
|
||||
else:
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
from SocketServer import ThreadingMixIn
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
+1
-6
@@ -1,13 +1,8 @@
|
||||
import abc
|
||||
import sys
|
||||
|
||||
from collections import namedtuple
|
||||
from helpers.utils import calculate_ttl, sleep
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
from urllib.parse import urlparse, urlunparse, parse_qsl
|
||||
else:
|
||||
from urlparse import urlparse, urlunparse, parse_qsl
|
||||
from six.moves.urllib_parse import urlparse, urlunparse, parse_qsl
|
||||
|
||||
|
||||
def parse_connection_string(value):
|
||||
|
||||
@@ -3,15 +3,13 @@ import os
|
||||
import psycopg2
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import six
|
||||
|
||||
from helpers.utils import sleep
|
||||
from six.moves.urllib_parse import urlparse
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
from urllib.parse import urlparse
|
||||
if six.PY3:
|
||||
long = int
|
||||
else:
|
||||
from urlparse import urlparse
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ dnspython
|
||||
psycopg2
|
||||
PyYAML
|
||||
requests
|
||||
six
|
||||
kazoo>=2.2.1
|
||||
|
||||
@@ -3,4 +3,5 @@ dnspython3
|
||||
psycopg2
|
||||
PyYAML
|
||||
requests
|
||||
six
|
||||
kazoo>=2.2.1
|
||||
|
||||
+1
-5
@@ -4,11 +4,7 @@ import unittest
|
||||
|
||||
from helpers.api import RestApiHandler, RestApiServer
|
||||
from test_postgresql import psycopg2_connect
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
from io import BytesIO as IO
|
||||
else:
|
||||
from StringIO import StringIO as IO
|
||||
from six import BytesIO as IO
|
||||
|
||||
|
||||
def throws(*args, **kwargs):
|
||||
|
||||
@@ -11,16 +11,12 @@ import yaml
|
||||
from patroni import Patroni, main
|
||||
from helpers.dcs import Cluster, Member
|
||||
from helpers.zookeeper import ZooKeeper
|
||||
from six.moves import BaseHTTPServer
|
||||
from test_etcd import requests_get, requests_put, requests_delete
|
||||
from test_ha import true, false
|
||||
from test_postgresql import Postgresql, subprocess_call, psycopg2_connect
|
||||
from test_zookeeper import MockKazooClient
|
||||
|
||||
if sys.hexversion >= 0x03000000:
|
||||
import http.server as BaseHTTPServer
|
||||
else:
|
||||
import BaseHTTPServer
|
||||
|
||||
|
||||
def nop(*args, **kwargs):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user