[GRASS-dev] [GRASS GIS] #2468: Python OSError: [Errno 7] Argument list too long when running grass.pipe_command repeatedly
GRASS GIS
trac at osgeo.org
Fri Jun 12 15:09:14 PDT 2015
#2468: Python OSError: [Errno 7] Argument list too long when running
grass.pipe_command repeatedly
----------------------+---------------------------------------------------
Reporter: maxnova | Owner: grass-dev@…
Type: defect | Status: closed
Priority: normal | Milestone: 6.4.5
Component: Python | Version: 6.4.4
Resolution: fixed | Keywords: OSError, pipe_command, python, script
CPU: x86-64 | Platform: Linux
----------------------+---------------------------------------------------
Comment (by wenzeslaus):
Replying to [comment:2 maxnova]:
> For anyone else that runs across this issue, I've updated the
demonstration code with the fix described above: https://gist.github.com
/max-nova/487a82de00651a33f2c2
Since the link to code appeared again on mailing list, it is worth noting
that that the main issue was calling `init` function multiple times
instead of just once (for ''initialization''). (The ticket should have
been ideally closed as ''invalid'' or at least ''wontfix''.)
The linked code is potentially doing same mistake, setting `GISRC`
variable and file multiple times. If this is an actual mistake depends on
how the code is used, but in general, it is enough to set `GISRC` just
once and change the file content to change the Mapset.
In some cases it is also advantageous to use `os.environ.copy()` to copy
environment to dictionary, modify it (e.g. `env['GISRC'] = ...`) and then
pass it as
[https://docs.python.org/2/library/subprocess.html#subprocess.Popen env
parameter] of a function from `grass.script.start_command()` family.
To learn more about this topic:
* [http://grass.osgeo.org/grass71/manuals/libpython/script.html#module-
script.setup grass.script.setup documentation] (recently updated)
* [http://grass.osgeo.org/grass71/manuals/grass7.html#exec-interface-
example --exec parameter of grass command] (available in trunk, upcoming
7.1 release, #2579)
* user wiki:
[http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly
Working with GRASS without starting it explicitly]
* grass-dev: [http://lists.osgeo.org/pipermail/grass-
dev/2015-June/075207.html How GRASS should behave when another session is
already active?]
([http://comments.gmane.org/gmane.comp.gis.grass.devel/64536 Gmane], [http
://osgeo-org.1560.x6.nabble.com/How-GRASS-should-behave-when-another-
session-is-already-active-td5208559.html Nabble])
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2468#comment:3>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list