mirror of
https://github.com/samba-team/samba.git
synced 2025-12-14 20:23:54 +03:00
gp: Use read_file() instead of readfp()
readfp() is deprecated and could be removed in a future version of Python. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Andrew Bartlett
parent
34042677b7
commit
2b566979ac
@@ -362,9 +362,9 @@ class gp_inf_ext(gp_ext):
|
|||||||
inf_conf = ConfigParser(interpolation=None)
|
inf_conf = ConfigParser(interpolation=None)
|
||||||
inf_conf.optionxform = str
|
inf_conf.optionxform = str
|
||||||
try:
|
try:
|
||||||
inf_conf.readfp(StringIO(policy.decode()))
|
inf_conf.read_file(StringIO(policy.decode()))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
inf_conf.readfp(StringIO(policy.decode('utf-16')))
|
inf_conf.read_file(StringIO(policy.decode('utf-16')))
|
||||||
return inf_conf
|
return inf_conf
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class GPIniParser(GPParser):
|
|||||||
interpolation=None)
|
interpolation=None)
|
||||||
self.ini_conf.optionxform = str
|
self.ini_conf.optionxform = str
|
||||||
|
|
||||||
self.ini_conf.readfp(StringIO(contents.decode(self.encoding)))
|
self.ini_conf.read_file(StringIO(contents.decode(self.encoding)))
|
||||||
|
|
||||||
def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
|
def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
|
||||||
child = SubElement(section_xml, 'Parameter')
|
child = SubElement(section_xml, 'Parameter')
|
||||||
@@ -117,7 +117,7 @@ class GPTIniParser(GPIniParser):
|
|||||||
self.ini_conf.optionxform = str
|
self.ini_conf.optionxform = str
|
||||||
|
|
||||||
# Fallback to Latin-1 which RSAT appears to use
|
# Fallback to Latin-1 which RSAT appears to use
|
||||||
self.ini_conf.readfp(StringIO(contents.decode('iso-8859-1')))
|
self.ini_conf.read_file(StringIO(contents.decode('iso-8859-1')))
|
||||||
|
|
||||||
|
|
||||||
class GPScriptsIniParser(GPIniParser):
|
class GPScriptsIniParser(GPIniParser):
|
||||||
|
|||||||
@@ -2358,9 +2358,9 @@ PasswordComplexity Password must meet complexity requirements
|
|||||||
inf_data.optionxform=str
|
inf_data.optionxform=str
|
||||||
raw = conn.loadfile(inf_file)
|
raw = conn.loadfile(inf_file)
|
||||||
try:
|
try:
|
||||||
inf_data.readfp(StringIO(raw.decode()))
|
inf_data.read_file(StringIO(raw.decode()))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
inf_data.readfp(StringIO(raw.decode('utf-16')))
|
inf_data.read_file(StringIO(raw.decode('utf-16')))
|
||||||
except NTSTATUSError as e:
|
except NTSTATUSError as e:
|
||||||
if e.args[0] == NT_STATUS_ACCESS_DENIED:
|
if e.args[0] == NT_STATUS_ACCESS_DENIED:
|
||||||
raise CommandError("The authenticated user does "
|
raise CommandError("The authenticated user does "
|
||||||
@@ -2453,9 +2453,9 @@ samba-tool gpo manage security list {31B2F340-016D-11D2-945F-00C04FB984F9}
|
|||||||
inf_data.optionxform=str
|
inf_data.optionxform=str
|
||||||
raw = conn.loadfile(inf_file)
|
raw = conn.loadfile(inf_file)
|
||||||
try:
|
try:
|
||||||
inf_data.readfp(StringIO(raw.decode()))
|
inf_data.read_file(StringIO(raw.decode()))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
inf_data.readfp(StringIO(raw.decode('utf-16')))
|
inf_data.read_file(StringIO(raw.decode('utf-16')))
|
||||||
except NTSTATUSError as e:
|
except NTSTATUSError as e:
|
||||||
if e.args[0] in [NT_STATUS_OBJECT_NAME_INVALID,
|
if e.args[0] in [NT_STATUS_OBJECT_NAME_INVALID,
|
||||||
NT_STATUS_OBJECT_NAME_NOT_FOUND,
|
NT_STATUS_OBJECT_NAME_NOT_FOUND,
|
||||||
|
|||||||
Reference in New Issue
Block a user