Skip to content

Commit

Permalink
g.proj: fix reading input WKT (OSGeo#1582)
Browse files Browse the repository at this point in the history
properly terminate input WKT string

Co-authored-by: Marc Jansen <jansen@terrestris.de>
  • Loading branch information
a0x8o and marcjansen committed Sep 5, 2024
1 parent f32db83 commit ce2c36a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -2745,6 +2746,7 @@ RUN pip3 install --upgrade grass-session
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> osgeo-main
Expand Down Expand Up @@ -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`
Expand Down
8 changes: 8 additions & 0 deletions general/g.proj/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ int input_wkt(char *wktfile)
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> main
=======
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -276,6 +279,7 @@ int input_wkt(char *wktfile)
=======
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> main
=======
<<<<<<< HEAD
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(self, parent, giface, menuModel):
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
<<<<<<< HEAD
<<<<<<< HEAD
Expand Down Expand Up @@ -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"""
Expand Down
6 changes: 6 additions & 0 deletions python/grass/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> main
=======
Expand Down Expand Up @@ -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))
Expand All @@ -142,6 +145,7 @@ ignore =
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> c1a5635118 (g.proj: fix reading input WKT (#1582))
=======
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
=======
Expand Down Expand Up @@ -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):
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce2c36a

Please sign in to comment.