Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/grass/pygrass/modules/interface/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ def G_debug(level, *msg):
if debug_level >= level:
dfile = os.environ.get("GRASS_DEBUG_FILE")
fd = sys.stderr if dfile is None else open(dfile, mode="a")
print("D%d/%d: " % (level, debug_level), *msg, end="\n", file=fd)
try:
print("D%d/%d: " % (level, debug_level), *msg, end="\n", file=fd)
finally:
if dfile is not None:
fd.close()
3 changes: 2 additions & 1 deletion raster/r.in.gdal/testsuite/test_r_in_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ def test_netCDF_3d_5(self):
test_gdal_import_map.0000000105
"""

text_from_file = open("map_names_file.txt").read()
with open("map_names_file.txt") as file:
text_from_file = file.read()

self.assertLooksLike(map_list, text_from_file)

Expand Down
9 changes: 7 additions & 2 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,8 @@ def install_extension_win(name):
if fullname not in old_file_list:
file_list.append(fullname)

if outdev is not sys.stdout:
outdev.close()
return 0, module_list, file_list


Expand Down Expand Up @@ -1780,8 +1782,9 @@ def is_binary_string(bytes):
for root, unused, files in os.walk(directory):
for name in files:
filename = os.path.join(root, name)
if is_binary_string(open(filename, "rb").read(1024)):
continue # ignore binary files
with open(filename, "rb") as file:
if is_binary_string(file.read(1024)):
continue # ignore binary files

# read content of text file
data = Path(filename).read_bytes()
Expand Down Expand Up @@ -2183,6 +2186,8 @@ def install_extension_std_platforms(name, source, url, branch):
if fullname not in old_file_list:
file_list.append(fullname)

if outdev is not sys.stdout:
outdev.close()
return ret, module_list, file_list, os.path.join(srcdir)


Expand Down
6 changes: 6 additions & 0 deletions scripts/m.proj/m.proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,14 @@ def main():
)
)

p.stdout.close()
p.wait()

if inf is not sys.stdin:
inf.close()
if outf is not sys.stdout:
outf.close()

if p.returncode != 0:
gcore.warning(_("Projection transform probably failed, please investigate"))

Expand Down
Loading