<div dir="ltr"><div><br><br>On Sun, Dec 24, 2017 at 3:10 PM, Paulo van Breugel <<a href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a>> wrote:<br>><br>> Hi devs,<br>><br>> I am trying to create a new mapset and open that mapset using g.mapset. When doing this from the command line, I can import layers in the new mapset using r.in.gdal without problems.However, running this in a python script doesn't work. E.g., when I run:<br>><br>><br>> gs.run_command("g.mapset", flags="c", mapset="LST", location="latlon_clark66")<br>><br>><br>> Next, I try to import a layer:<br>><br>><br>> infile="lst_01.tif"<br>><br>> outfile="lst_01"<br>><br>> gs.run_command("r.in.gdal", input=infile, output=outfile)<br>><br>> This gives me the error:<br>><br>> gs.run_command("r.in.gdal", input="lst_01.tif", output="lst_01")<br>><br>> Traceback (most recent call last):<br>><br>>   File "<ipython-input-18-2c415e16d79f>", line 1, in <module><br>><br>>     gs.run_command("r.in.gdal", input="lst_01.tif", output="lst_01")<br>><br>>   File "/usr/local/grass7/grass-7.5.svn/etc/python/grass/script/core.py", line 421, in run_command<br>><br>>     return handle_errors(returncode, returncode, args, kwargs)<br>><br>>   File "/usr/local/grass7/grass-7.5.svn/etc/python/grass/script/core.py", line 332, in handle_errors<br>><br>>     returncode=returncode)<br>><br>> CalledModuleError: Module run None ['r.in.gdal', 'input=lst_01.tif', 'output=lst_01'] ended with error<br>><br>> Process ended with non-zero return code 1. See errors in the (error) output.<br>><br>><br>> Any idea why this doesn't work?<br><br></div>It is a pity that the output to stderr is not available when a module is called in python with gs.run_command() and the module fails. The python traceback is in this case useless. Maybe handle_errors() [0] could be improved to also provide the stderr output of the current module.<br><div><br></div><div>Markus M<br></div><div><br></div><div>[0] <a href="https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/core.py#L318">https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/core.py#L318</a><br></div><div>><br>> Best wishes,<br>><br>> Paulo<br>><br>><br>><br>> _______________________________________________<br>> grass-dev mailing list<br>> <a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-dev">https://lists.osgeo.org/mailman/listinfo/grass-dev</a><br><br></div></div>