From 8432ca2b48385e4372fed306329f03185b46a620 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Wed, 11 Apr 2018 16:03:34 +1200 Subject: [PATCH] python: bulk replace file to open for py3 The builtin function `file` was removed in py3. Use `open` instead. Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- python/samba/netcmd/gpo.py | 6 +++--- python/samba/provision/sambadns.py | 2 +- python/samba/subunit/run.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 5f4ad0ebca0..cd946d9fa72 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -252,7 +252,7 @@ def copy_directory_remote_to_local(conn, remotedir, localdir): os.mkdir(l_name) else: data = conn.loadfile(r_name) - file(l_name, 'w').write(data) + open(l_name, 'w').write(data) def copy_directory_local_to_remote(conn, localdir, remotedir): @@ -274,7 +274,7 @@ def copy_directory_local_to_remote(conn, localdir, remotedir): r_dirs.append(r_name) conn.mkdir(r_name) else: - data = file(l_name, 'r').read() + data = open(l_name, 'r').read() conn.savefile(r_name, data) @@ -943,7 +943,7 @@ class cmd_create(Command): os.mkdir(os.path.join(gpodir, "Machine")) os.mkdir(os.path.join(gpodir, "User")) gpt_contents = "[General]\r\nVersion=0\r\n" - file(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents) + open(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents) except Exception as e: raise CommandError("Error Creating GPO files", e) diff --git a/python/samba/provision/sambadns.py b/python/samba/provision/sambadns.py index 7a85546c53e..3d59c701066 100644 --- a/python/samba/provision/sambadns.py +++ b/python/samba/provision/sambadns.py @@ -806,7 +806,7 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid): domainpart_file = os.path.join(dns_dir, partfile[domaindn]) try: os.mkdir(dns_samldb_dir) - file(domainpart_file, 'w').close() + open(domainpart_file, 'w').close() # Fill the basedn and @OPTION records in domain partition dom_url = "%s://%s" % (backend_store, domainpart_file) diff --git a/python/samba/subunit/run.py b/python/samba/subunit/run.py index bb598b42452..8f32d46ef49 100755 --- a/python/samba/subunit/run.py +++ b/python/samba/subunit/run.py @@ -79,7 +79,7 @@ class TestProtocolClient(unittest.TestResult): suite = make_suite() # Create a stream (any object with a 'write' method). This should accept # bytes not strings: subunit is a byte orientated protocol. - stream = file('tests.log', 'wb') + stream = open('tests.log', 'wb') # Create a subunit result object which will output to the stream result = subunit.TestProtocolClient(stream) # Optionally, to get timing data for performance analysis, wrap the