From 01fcce31dcd13f201924e0a18e43fe3d6ff31c33 Mon Sep 17 00:00:00 2001 From: Alex Barreto Date: Mon, 17 May 2021 11:45:55 -0400 Subject: [PATCH] g.proj: fix reading input WKT (#1582) properly terminate input WKT string Co-authored-by: Marc Jansen --- docker/alpine/Dockerfile | 7 +++++++ general/g.proj/input.c | 8 ++++++++ gui/wxpython/gui_core/prompt.py | 6 ++++++ python/grass/.flake8 | 6 ++++++ scripts/g.extension/g.extension.py | 32 ++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 7c1a3d237a7..fedb026ff25 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -2449,6 +2449,7 @@ RUN apk add curl && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && p ======= >>>>>>> 75dcc66eed (Dockerfile_alpine: fix broken pip six installation (#1568)) <<<<<<< HEAD:docker/alpine/Dockerfile +<<<<<<< HEAD:docker/alpine/Dockerfile RUN pip3 install --upgrade pip six grass-session --ignore-installed six ======= RUN pip3 install --upgrade grass-session @@ -2466,6 +2467,7 @@ RUN pip3 install --upgrade grass-session <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> osgeo-main @@ -2754,6 +2756,11 @@ RUN pip3 install --upgrade pip six grass-session --ignore-installed six >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) ======= >>>>>>> 75dcc66eed (Dockerfile_alpine: fix broken pip six installation (#1568)) +======= +======= +RUN pip3 install --upgrade pip six grass-session --ignore-installed six +>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)):docker/alpine/Dockerfile_alpine +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) RUN ln -s /usr/local/grass /usr/local/grass7 RUN ln -s /usr/local/grass `grass --config path` diff --git a/general/g.proj/input.c b/general/g.proj/input.c index 9313b6fbdda..85d673930d7 100644 --- a/general/g.proj/input.c +++ b/general/g.proj/input.c @@ -140,6 +140,7 @@ int input_wkt(char *wktfile) <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -229,6 +230,8 @@ int input_wkt(char *wktfile) >>>>>>> osgeo-main ======= >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +======= +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) size_t wktlen; wktlen = fread(buff, 1, sizeof(buff), infd); @@ -257,6 +260,7 @@ int input_wkt(char *wktfile) <<<<<<< HEAD ======= <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> main ======= <<<<<<< HEAD @@ -348,6 +352,10 @@ int input_wkt(char *wktfile) ======= ======= >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +======= +======= +>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)) +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) size_t wktlen; wktlen = fread(buff, 1, sizeof(buff), infd); diff --git a/gui/wxpython/gui_core/prompt.py b/gui/wxpython/gui_core/prompt.py index d74d3ccdc0d..fbce16721a3 100644 --- a/gui/wxpython/gui_core/prompt.py +++ b/gui/wxpython/gui_core/prompt.py @@ -86,6 +86,7 @@ def __init__(self, parent, giface, menuModel): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= <<<<<<< HEAD <<<<<<< HEAD @@ -166,6 +167,11 @@ def __init__(self, parent, giface, menuModel): ======= ======= >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +======= +======= +======= +>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)) +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) def _readHistory(self): """Get list of commands from history file""" diff --git a/python/grass/.flake8 b/python/grass/.flake8 index 4238d55f2c9..303d7f67b68 100644 --- a/python/grass/.flake8 +++ b/python/grass/.flake8 @@ -33,6 +33,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -104,6 +105,8 @@ ignore = ======= >>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582)) >>>>>>> osgeo-main +======= +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) ======= E722, # do not use bare 'except' >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) @@ -125,6 +128,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 95f198e1e0 (g.proj: fix reading input WKT (#1582)) ======= @@ -291,6 +295,8 @@ ignore = E722, # do not use bare 'except' >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) >>>>>>> 3ced907ea6 (pythonlib: Remove star imports (#1546)) +======= +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) per-file-ignores = # C wrappers call libgis.G_gisinit before importing other modules. diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py index 74e3afee149..835c521bc88 100644 --- a/scripts/g.extension/g.extension.py +++ b/scripts/g.extension/g.extension.py @@ -1184,6 +1184,29 @@ def replace_shebang_win(python_file): >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +def replace_shebang_win(python_file): + """ + Replaces "python" with "python3" in python files + using UTF8 encoding on MS Windows + """ + + cur_dir = os.path.dirname(python_file) + tmp_name = os.path.join(cur_dir, gscript.tempname(12)) + + with codecs.open(python_file, "r", encoding="utf8") as in_file, codecs.open( + tmp_name, "w", encoding="utf8" + ) as out_file: + + for line in in_file: + new_line = line.replace( + "#!/usr/bin/env python\n", "#!/usr/bin/env python3\n" + ) + out_file.write(new_line) + + os.remove(python_file) # remove original + os.rename(tmp_name, python_file) # rename temp to original name + + def urlretrieve(url, filename, *args, **kwargs): """Same function as 'urlretrieve', but with the ability to define headers. @@ -3766,6 +3789,7 @@ def install_extension_win(name): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file): ======= @@ -3805,6 +3829,8 @@ def install_extension_win(name): >>>>>>> osgeo-main ======= >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +======= +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) if re.search(module_name_pattern, file): ======= if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file): @@ -3821,6 +3847,7 @@ def install_extension_win(name): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file): >>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)) @@ -3891,6 +3918,11 @@ def install_extension_win(name): >>>>>>> osgeo-main ======= >>>>>>> 460748a7fb (g.proj: fix reading input WKT (#1582)) +======= +======= + if re.search(r"^[d,db,g,i,m,p,ps,r,r3,s,t,v,wx]\..*[\.py,\.exe]$", file): +>>>>>>> 7c10386e82 (g.proj: fix reading input WKT (#1582)) +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) modulename = os.path.splitext(file)[0] module_list.append(modulename) # remove duplicates in case there are .exe wrappers for python scripts