From ce2c36a33f028787da5af6ea6021b6738e5b86b0 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 21b4e2c73ff..d2e27efc4e8 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -2726,6 +2726,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 @@ -2745,6 +2746,7 @@ RUN pip3 install --upgrade grass-session <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> osgeo-main @@ -3078,6 +3080,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 9729535e2dd..fde2c003a78 100644 --- a/general/g.proj/input.c +++ b/general/g.proj/input.c @@ -145,6 +145,7 @@ int input_wkt(char *wktfile) <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -246,6 +247,8 @@ int input_wkt(char *wktfile) >>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582)) ======= >>>>>>> 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); @@ -276,6 +279,7 @@ int input_wkt(char *wktfile) ======= <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> main ======= <<<<<<< HEAD @@ -380,6 +384,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 626d4bcb2ab..08d488b5aca 100644 --- a/gui/wxpython/gui_core/prompt.py +++ b/gui/wxpython/gui_core/prompt.py @@ -88,6 +88,7 @@ def __init__(self, parent, giface, menuModel): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= <<<<<<< HEAD <<<<<<< HEAD @@ -176,6 +177,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 33fe20a254c..11c73a89b85 100644 --- a/python/grass/.flake8 +++ b/python/grass/.flake8 @@ -39,6 +39,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> main ======= @@ -118,6 +119,8 @@ ignore = ======= >>>>>>> 7e7871fd90 (g.proj: fix reading input WKT (#1582)) >>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582)) +======= +>>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) ======= E722, # do not use bare 'except' >>>>>>> 7e8f036e2d (pythonlib: Remove star imports (#1546)) @@ -142,6 +145,7 @@ ignore = <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582)) ======= @@ -333,6 +337,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 8d452b75596..7a029bfc564 100644 --- a/scripts/g.extension/g.extension.py +++ b/scripts/g.extension/g.extension.py @@ -1290,6 +1290,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. @@ -4019,6 +4042,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): ======= @@ -4062,6 +4086,8 @@ def install_extension_win(name): >>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) ======= >>>>>>> 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): @@ -4080,6 +4106,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)) @@ -4157,6 +4184,11 @@ def install_extension_win(name): >>>>>>> 9fb6588182 (g.proj: fix reading input WKT (#1582)) ======= >>>>>>> 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