Re: [GRASS-dev] Catching an issue from external binary using grass Python Script
You are absolutely right. I made a mistake. I meant p=subprocess.call() If you use subprocess.call(), the return value is the return code of > the child process. > > But In this case I obtain this in Command Output window: >* This application has requested the Runtime to terminate it*>* in an unusual >way.*>* Please contact the application's support team for more*>* information.* *and my p is 3 (don't know why because in no place of the binary there is any return 3)* *Is it possible to get above text ("This application ..." in a variable?* *Thanks* *Jenny* > If you use subprocess.Popen(), the .wait() method returns the child > process' return code, which can also be retrieved from the .returncode > attribute of the Popen object. > > Typically, a return code of zero indicates success while a non-zero > value indicates failure. On Unix, a negative value indicates that the > process terminated due to a signal. > > Neither call() nor Popen() raise an exception if the spawned program > "fails" in some sense, only if they are unable to execute the program, > query its status, etc. > > -- > Glynn Clements > ___ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev
[GRASS-dev] Catching an issue from external binary using grass Python Script
Greetings I have a Grass Python script that calls an external binary using subprocess like: p=subprocess(). Due to some limitations (memory) sometimes i get this copied into Command Output: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. (this is windows) 1- How can catch this error (with except but I don't know which error to use Thanks Jenny ___ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev
[GRASS-dev] Compiling and running a module in winGRASS- not running in Win7 but yes in XP
Greetings I have built a GRASS module to perform image segmentation. But, to have this running fine I neeeded 1- g++ -fpic -c segmentimage.cpp 2- g++ -shared -o libsegmentimage.dll segmentimage.o 3- Placed .dll file in lib folder of dist folder in OSGEO4w 4- added -lsegmentimage in makefile 5- compiled successfully with make -C i.segment MODULE_TOPDIR=/C/OSGeo4W/usr/src/grass-6.4.svn make: Entering directory `/c/osgeo4w/usr/src/i.segment' gcc -L/c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-ming w32/lib -Wl,--export-dynamic,--enable-runtime-pseudo-reloc -L/c/OSGeo4W/apps/gd al-16/lib -L/c/OSGeo4W/lib -o /c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32/bin/i.segment.exe OBJ.i686-pc-mingw32/hist.o OBJ.i686-pc-mingw32/main.o OBJ.i686-pc-mingw32/open.o /C/OSGeo4W/usr/src/grass-6.4. svn/lib/gis/OBJ.i686-pc-mingw32/fmode.o -lgrass_I -lgras s_gis -lgrass_datetime -lxdr -liberty -lws2_32-lz -lintl -lgrass_gis -lg rass_datetime -lxdr -liberty -lws2_32-lz -lintl -lgrass_gmath -lgrass_gis -lgrass_datetime -lxdr -liberty -lws2_32-lz -lintl -lsegmentimage -lxd r -liberty -lws2_32-lz make htmlcmd make[1]: Entering directory `/c/osgeo4w/usr/src/i.segment' make /c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw 32/docs/html/i.segment.html HTMLSRC=/c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32/bin/i.segment.exe make[2]: Entering directory `/c/osgeo4w/usr/src/i.segment' if [ "/c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-ming w32/bin/i.segment.exe" != "" ] ; then GISRC=/c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32/demolocation/.grassrc64 GISBASE=c:/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32 PATH="/c /osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32/bin: $PATH" PATH="/c/osgeo4w/usr/src/grass-6.4.svn/dist.i686- pc-mingw32/bin:/c/osgeo4w/usr/src/grass-6.4.svn/dist.i68 6-pc-mingw32/lib:.:/usr/local/bin:/mingw/bin:/bin:/osgeo4/bin:/osgeo4/bin:/c/Pro gram Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/Com mon Files/Microsoft Shared/Windows Live:/c/Windows/system32:/c/Windows:/c/Window s/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files (x8 6)/ATI Technologies/ATI.ACE/Core-Static:/c/MATLAB7/bin/win32:/c/Program Files (x 86)/Windows Live/Shared:.:/bin:/bin" LC_ALL=C /c/osgeo4w/usr/src/grass-6.4.svn/dist.i686-pc-mingw32/bin/i.segment.exe --html-description < /dev/null | grep -v '\|' > i.segment.tmp.html ; true ; fi /C/OSGeo4W/usr/src/grass-6.4.svn/tools/mkhtml.sh i.segme nt ; mkdir -p /c/osgeo4w/usr/src/grass-6.4.svn/dist.i686 -pc-mingw32/docs/html ; /bin/install -c -m 644 i.segment.tmp.html /c/osgeo4w/us r/src/grass-6.4.svn_src_snapshot_2010_09_04/dist.i686-pc-mingw32/docs/html/i.seg ment.html ; for file in *.png *.jpg ; do head -n 1 $file | grep '^#!' > /dev/nu ll ; if [ $? -ne 0 ] ; then /bin/install -c -m 644 $file /c/osgeo4w/usr/src/gra ss-6.4.svn/dist.i686-pc-mingw32/docs/html ; fi done 2> / dev/null ; true make[2]: Leaving directory `/c/osgeo4w/usr/src/i.segment' make[1]: Leaving directory `/c/osgeo4w/usr/src/i.segment' make mancmd make[1]: Entering directory `/c/osgeo4w/usr/src/i.segment' make[1]: Nothing to be done for `mancmd'. make[1]: Leaving directory `/c/osgeo4w/usr/src/i.segment' make: Leaving directory `/c/osgeo4w/usr/src/i.segment' This was built in Msys in a Win7 machine 6- Then I placed exe and dll in OSGEO4w/apps/grass/grass6.4.1svn/bin 7- I runned in WinGRASS in WinXP and it runned just fine 8- I runned in WinGRASS in Win7 and I got a pop window checking error and the following was printed in GRASS Command window: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. HAs anyone an idea of what might be happening? Thanks Jenny [GRASS]- Running a module in Win7 and XP Reply Jenny Turner to hellik show details 1:24 AM (9 hours ago) Greetings I have built a module, with a shared .dll file, and I've been able to run it in WinXP but not in Win7. In Win/ i get: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Do you have any advice on what might be happening? The weirdest thing is that I have compiled with OSGEO4W in Win7 not in WinXP. If you want, or if you are able to help me, I can send you my code and my process. W