mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
python compat: remove binary_type
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
parent
bcaf076d30
commit
ace5038031
@ -73,7 +73,6 @@ if PY3:
|
||||
|
||||
# compat types
|
||||
text_type = str
|
||||
binary_type = bytes
|
||||
|
||||
# alias
|
||||
def ConfigParser(defaults=None, dict_type=dict, allow_no_value=False):
|
||||
|
@ -101,7 +101,6 @@ from samba.provision.common import (
|
||||
from samba.netcmd.pso import cmd_domain_passwordsettings_pso
|
||||
from samba.netcmd.domain_backup import cmd_domain_backup
|
||||
|
||||
from samba.compat import binary_type
|
||||
from samba.compat import get_string
|
||||
|
||||
string_version_to_constant = {
|
||||
@ -536,7 +535,7 @@ class cmd_domain_provision(Command):
|
||||
def _adminpass_issue(self, adminpass):
|
||||
"""Returns error string for a bad administrator password,
|
||||
or None if acceptable"""
|
||||
if isinstance(adminpass, binary_type):
|
||||
if isinstance(adminpass, bytes):
|
||||
adminpass = adminpass.decode('utf8')
|
||||
if len(adminpass) < DEFAULT_MIN_PWD_LENGTH:
|
||||
return "Administrator password does not meet the default minimum" \
|
||||
|
@ -27,7 +27,6 @@
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
from urllib.parse import quote as urllib_quote
|
||||
from samba.compat import binary_type
|
||||
from base64 import b64encode
|
||||
import errno
|
||||
import os
|
||||
@ -2332,7 +2331,7 @@ def provision(logger, session_info, smbconf=None,
|
||||
adminpass = samba.generate_random_password(12, 32)
|
||||
adminpass_generated = True
|
||||
else:
|
||||
if isinstance(adminpass, binary_type):
|
||||
if isinstance(adminpass, bytes):
|
||||
adminpass = adminpass.decode('utf-8')
|
||||
adminpass_generated = False
|
||||
|
||||
|
@ -33,7 +33,6 @@ from samba.ndr import ndr_unpack, ndr_pack
|
||||
from samba.dcerpc import drsblobs, misc
|
||||
from samba.common import normalise_int32
|
||||
from samba.compat import text_type
|
||||
from samba.compat import binary_type
|
||||
from samba.compat import get_bytes
|
||||
from samba.dcerpc import security
|
||||
|
||||
@ -1098,7 +1097,7 @@ schemaUpdateNow: 1
|
||||
return dn
|
||||
|
||||
def set_minPwdAge(self, value):
|
||||
if not isinstance(value, binary_type):
|
||||
if not isinstance(value, bytes):
|
||||
value = str(value).encode('utf8')
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(self, self.domain_dn())
|
||||
@ -1115,7 +1114,7 @@ schemaUpdateNow: 1
|
||||
return int(res[0]["minPwdAge"][0])
|
||||
|
||||
def set_maxPwdAge(self, value):
|
||||
if not isinstance(value, binary_type):
|
||||
if not isinstance(value, bytes):
|
||||
value = str(value).encode('utf8')
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(self, self.domain_dn())
|
||||
@ -1132,7 +1131,7 @@ schemaUpdateNow: 1
|
||||
return int(res[0]["maxPwdAge"][0])
|
||||
|
||||
def set_minPwdLength(self, value):
|
||||
if not isinstance(value, binary_type):
|
||||
if not isinstance(value, bytes):
|
||||
value = str(value).encode('utf8')
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(self, self.domain_dn())
|
||||
@ -1149,7 +1148,7 @@ schemaUpdateNow: 1
|
||||
return int(res[0]["minPwdLength"][0])
|
||||
|
||||
def set_pwdProperties(self, value):
|
||||
if not isinstance(value, binary_type):
|
||||
if not isinstance(value, bytes):
|
||||
value = str(value).encode('utf8')
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(self, self.domain_dn())
|
||||
|
@ -33,7 +33,6 @@ import samba.dcerpc.lsa
|
||||
import struct
|
||||
from samba import gensec
|
||||
from samba.tests.dcerpc.raw_testcase import RawDCERPCTest
|
||||
from samba.compat import binary_type
|
||||
from samba.ntstatus import (
|
||||
NT_STATUS_SUCCESS
|
||||
)
|
||||
@ -1930,12 +1929,12 @@ class TestDCERPC_BIND(RawDCERPCTest):
|
||||
epmap=True, return_ack=True)
|
||||
|
||||
server = '\\\\' + self.target_hostname
|
||||
if isinstance(server, binary_type):
|
||||
if isinstance(server, bytes):
|
||||
server_utf16 = server.decode('utf-8').encode('utf-16-le')
|
||||
else:
|
||||
server_utf16 = server.encode('utf-16-le')
|
||||
computer = 'UNKNOWNCOMPUTER'
|
||||
if isinstance(server, binary_type):
|
||||
if isinstance(server, bytes):
|
||||
computer_utf16 = computer.decode('utf-8').encode('utf-16-le')
|
||||
else:
|
||||
computer_utf16 = computer.encode('utf-16-le')
|
||||
|
@ -27,7 +27,6 @@ import random
|
||||
import socket
|
||||
import uuid
|
||||
import time
|
||||
from samba.compat import binary_type
|
||||
|
||||
|
||||
class DNSTest(TestCaseInTempDir):
|
||||
@ -278,7 +277,7 @@ class DNSTKeyTest(DNSTest):
|
||||
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
|
||||
|
||||
tkey_record = response.answers[0].rdata
|
||||
server_to_client = binary_type(bytearray(tkey_record.key_data))
|
||||
server_to_client = bytes(tkey_record.key_data)
|
||||
(finished, client_to_server) = self.g.update(server_to_client)
|
||||
self.assertTrue(finished)
|
||||
|
||||
@ -288,7 +287,7 @@ class DNSTKeyTest(DNSTest):
|
||||
self.assertEqual(response.additional[0].rr_type, dns.DNS_QTYPE_TSIG)
|
||||
|
||||
tsig_record = response.additional[0].rdata
|
||||
mac = binary_type(bytearray(tsig_record.mac))
|
||||
mac = bytes(tsig_record.mac)
|
||||
|
||||
# Cut off tsig record from dns response packet for MAC verification
|
||||
# and reset additional record count.
|
||||
@ -305,7 +304,7 @@ class DNSTKeyTest(DNSTest):
|
||||
response_packet_list[11] = chr(0)
|
||||
|
||||
# convert modified list (of string char or int) to str/bytes
|
||||
response_packet_wo_tsig = binary_type(bytearray(response_packet_list))
|
||||
response_packet_wo_tsig = bytes(response_packet_list)
|
||||
|
||||
fake_tsig = dns.fake_tsig_rec()
|
||||
fake_tsig.name = self.key_name
|
||||
|
@ -26,7 +26,6 @@ from samba import subunit
|
||||
from samba.subunit.run import TestProtocolClient
|
||||
from samba.subunit import iso8601
|
||||
import unittest
|
||||
from samba.compat import binary_type
|
||||
|
||||
|
||||
VALID_RESULTS = set(['success', 'successful', 'failure', 'fail', 'skip',
|
||||
@ -93,7 +92,7 @@ def parse_results(msg_ops, statistics, fh):
|
||||
else:
|
||||
reason += l
|
||||
|
||||
if isinstance(reason, binary_type):
|
||||
if isinstance(reason, bytes):
|
||||
remote_error = subunit.RemoteError(reason.decode("utf-8"))
|
||||
else:
|
||||
remote_error = subunit.RemoteError(reason)
|
||||
|
Loading…
Reference in New Issue
Block a user