Commit c7a4b968 authored by maxbecke's avatar maxbecke
Browse files

Revert "Support Python 3"

This reverts the commits:
880da73a
b6b0d993
parent 880da73a
......@@ -44,11 +44,6 @@ import threading
from contextlib import contextmanager
from logging.handlers import RotatingFileHandler
try:
from ConfigParser import NoOptionError
except Exception:
from configparser import NoOptionError
try:
import ConfigParser
except ImportError:
......@@ -79,11 +74,11 @@ DEFAULT_STUNNEL_VERIFY_LEVEL = 2
DEFAULT_STUNNEL_CAFILE = '/etc/amazon/efs/efs-utils.crt'
EFS_ONLY_OPTIONS = [
'noocsp',
'ocsp',
'tls',
'tlsport',
'verify'
'verify',
'ocsp',
'noocsp'
]
UNSUPPORTED_OPTIONS = [
......@@ -442,7 +437,7 @@ def create_state_file_dir(config, state_file_dir):
mode = int(mode_str, 8)
except ValueError:
logging.warn('Bad state_file_dir_mode "%s" in config file "%s"', mode_str, CONFIG_FILE)
except NoOptionError:
except ConfigParser.NoOptionError:
pass
try:
......@@ -590,10 +585,7 @@ def assert_root():
def read_config(config_file=CONFIG_FILE):
try:
p = ConfigParser.SafeConfigParser()
except AttributeError:
p = ConfigParser()
p = ConfigParser.SafeConfigParser()
p.read(config_file)
return p
......@@ -673,7 +665,7 @@ def match_device(config, device):
try:
primary, secondaries, _ = socket.gethostbyname_ex(remote)
hostnames = list(filter(lambda e: e is not None, [primary] + secondaries))
hostnames = filter(lambda e: e is not None, [primary] + secondaries)
except socket.gaierror:
fatal_error(
'Failed to resolve "%s" - check that the specified DNS name is a CNAME record resolving to a valid EFS DNS '
......@@ -706,7 +698,6 @@ def mount_tls(config, init_system, dns_name, path, fs_id, mountpoint, options):
with bootstrap_tls(config, init_system, dns_name, fs_id, mountpoint, options) as tunnel_proc:
mount_completed = threading.Event()
t = threading.Thread(target=poll_tunnel_process, args=(tunnel_proc, fs_id, mount_completed))
t.daemon = True
t.start()
mount_nfs(dns_name, path, mountpoint, options)
mount_completed.set()
......
......@@ -280,10 +280,7 @@ def assert_root():
def read_config(config_file=CONFIG_FILE):
try:
p = ConfigParser.SafeConfigParser()
except AttributeError:
p = ConfigParser()
p = ConfigParser.SafeConfigParser()
p.read(config_file)
return p
......
......@@ -30,7 +30,7 @@ def setup_mocks(mocker):
mocker.patch('mount_efs.start_watchdog')
mocker.patch('mount_efs.get_tls_port_range', return_value=(DEFAULT_TLS_PORT, DEFAULT_TLS_PORT + 10))
mocker.patch('socket.socket', return_value=MagicMock())
mocker.patch('mount_efs.write_tls_tunnel_state_file', return_value="~mocktempfile")
mocker.patch('mount_efs.write_tls_tunnel_state_file')
mocker.patch('os.rename')
mocker.patch('os.kill')
......
......@@ -7,26 +7,19 @@
#
import mount_efs
import ConfigParser
import socket
import pytest
from mock import MagicMock
try:
import ConfigParser
except ImportError:
from configparser import ConfigParser
DEFAULT_TLS_PORT_RANGE_LOW = 20049
DEFAULT_TLS_PORT_RANGE_HIGH = 20449
def _get_config():
try:
config = ConfigParser.SafeConfigParser()
except AttributeError:
config = ConfigParser()
config = ConfigParser.SafeConfigParser()
config.add_section(mount_efs.CONFIG_SECTION)
config.set(mount_efs.CONFIG_SECTION, 'port_range_lower_bound', str(DEFAULT_TLS_PORT_RANGE_LOW))
config.set(mount_efs.CONFIG_SECTION, 'port_range_upper_bound', str(DEFAULT_TLS_PORT_RANGE_HIGH))
......
......@@ -63,7 +63,7 @@ def test_get_dns_name_bad_format_wrong_specifiers(mocker):
with pytest.raises(ValueError) as ex:
mount_efs.get_dns_name(config, FS_ID)
assert 'must include' in str(ex)
assert 'must include' in ex.value.message
def test_get_dns_name_bad_format_too_many_specifiers_1(mocker):
......@@ -72,7 +72,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_1(mocker):
with pytest.raises(ValueError) as ex:
mount_efs.get_dns_name(config, FS_ID)
assert 'incorrect number' in str(ex)
assert 'incorrect number' in ex.value.message
def test_get_dns_name_bad_format_too_many_specifiers_2(mocker):
......@@ -81,7 +81,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_2(mocker):
with pytest.raises(ValueError) as ex:
mount_efs.get_dns_name(config, FS_ID)
assert 'incorrect number' in str(ex)
assert 'incorrect number' in ex.value.message
def test_get_dns_name_unresolvable(mocker, capsys):
......
......@@ -11,10 +11,7 @@ import json
import pytest
try:
from urllib2 import URLError
except ImportError:
from urllib.error import URLError
from urllib2 import URLError
INSTANCE_DATA = {
'devpayProductCodes': None,
......
......@@ -7,19 +7,13 @@
#
import mount_efs
import ConfigParser
import pytest
try:
import ConfigParser
except ImportError:
from configparser import ConfigParser
def _get_config(stunnel_check_cert_validity):
try:
config = ConfigParser.SafeConfigParser()
except AttributeError:
config = ConfigParser()
config = ConfigParser.SafeConfigParser()
config.add_section(mount_efs.CONFIG_SECTION)
if stunnel_check_cert_validity is not None:
config.set(mount_efs.CONFIG_SECTION, 'stunnel_check_cert_validity', str(stunnel_check_cert_validity))
......
......@@ -7,15 +7,11 @@
#
import mount_efs
import ConfigParser
import os
import pytest
try:
import ConfigParser
except ImportError:
from configparser import ConfigParser
FS_ID = 'fs-deadbeef'
DNS_NAME = 'fs-deadbeef.com'
MOUNT_POINT = '/mnt'
......@@ -37,10 +33,7 @@ def _get_config(mocker, stunnel_debug_enabled=False, stunnel_check_cert_hostname
if stunnel_check_cert_validity is None:
stunnel_check_cert_validity = stunnel_check_cert_validity_supported
try:
config = ConfigParser.SafeConfigParser()
except AttributeError:
config = ConfigParser()
config = ConfigParser.SafeConfigParser()
config.add_section(mount_efs.CONFIG_SECTION)
config.set(mount_efs.CONFIG_SECTION, 'stunnel_debug_enabled', str(stunnel_debug_enabled))
config.set(mount_efs.CONFIG_SECTION, 'stunnel_check_cert_hostname', str(stunnel_check_cert_hostname))
......
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