<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Sorry, I thought I had tested it with some changes I made
afterwards, this end part works better:<br>
<tt><br>
startcmd = 'python '+s.name</tt><tt><br>
</tt><tt> # set env variable</tt><tt><br>
</tt><tt> tmpdir = os.path.dirname(s.name)</tt><tt><br>
</tt><tt> os.environ['GRASS_ADDON_PATH']=tmpdir</tt><tt><br>
</tt><tt> # set permissions</tt><tt><br>
</tt><tt> os.chmod(s.name, os.stat(s.name).st_mode |
stat.S_IEXEC)</tt><tt><br>
</tt><tt> # start module</tt><tt><br>
</tt><tt> os.system(startcmd)</tt><tt><br>
</tt><tt> os.remove(s.name)</tt><br>
<br>
<div class="moz-cite-prefix">On 10/12/2015 12:55 PM, Blumentrath,
Stefan wrote:<br>
</div>
<blockquote
cite="mid:b5ef252e340c432a90f525d3bd13c941@NINSRV23.nina.no"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi again,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Now
I found out that the parser section in the inner python
script was not formated properly.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">However,
when I now call the inner script with ‘--ui’ I get an error:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Unable
to fetch interface description for command ‘tmpjksdfjiol’<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Details:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Try
to set up GRASS_ADDON_PATH or GRASS_ADDON_BASE variable.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">It
was neither possible to run the script using
grass.run_command() (on Windows).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Cheers<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-fareast-language:NO-BOK" lang="EN-US">From:</span></b><span
style="mso-fareast-language:NO-BOK" lang="EN-US">
grass-dev [<a class="moz-txt-link-freetext" href="mailto:grass-dev-bounces@lists.osgeo.org">mailto:grass-dev-bounces@lists.osgeo.org</a>]
<b>On Behalf Of </b>Blumentrath, Stefan<br>
<b>Sent:</b> 12. oktober 2015 11:36<br>
<b>To:</b> GRASS developers list
(<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>)
<a class="moz-txt-link-rfc2396E" href="mailto:grass-dev@lists.osgeo.org"><grass-dev@lists.osgeo.org></a><br>
<b>Subject:</b> [GRASS-dev] Using a dynamic text in
module header for parser<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">I would like to fill:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#% options:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">and<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#% answer<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">in a parser option for a
python script dynamically. In particular I want to have
tickboxes for available mapsets in the module GUI…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Meaning something like
this (but less complex / not interactive):<o:p></o:p></span></p>
<p class="MsoNormal"><a moz-do-not-send="true"
href="http://permalink.gmane.org/gmane.comp.gis.grass.gui/667"><span
lang="EN-US">http://permalink.gmane.org/gmane.comp.gis.grass.gui/667</span></a><span
lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">My amateur programming
skills do unfortunately not allow me to really understand
how to accomplish what Glynn describes in the post above…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I tried to generate and
run a temporary python script from within my script like
this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">def main():<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> answer =
grass.mapsets(search_path = True)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> available_mapsets =
str(grass.mapsets())<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> with
tempfile.NamedTemporaryFile(delete = False) as s:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> s.write('''
#!/usr/bin/env python<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"># -*- coding: utf-8 -*-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"># Here comes the full
module with header for the parser<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#% options: ''' +
str(','.join(available_mapsets))<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">’’’)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> startcmd = 'python '
+ s.name<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> os.system(startcmd)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> os.remove(s.name)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But that way the GUI
never starts, when I call the outer script from GRASS and it
seems that option never get parsed…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Any hints how to
proceed?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks for helping in
advance.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-dev">http://lists.osgeo.org/mailman/listinfo/grass-dev</a></pre>
</blockquote>
<br>
</body>
</html>