<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 31, 2014 at 1:10 PM, Heinz Chen <span dir="ltr"><<a href="mailto:liebenhans@gmail.com" target="_blank">liebenhans@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:pmingliu,serif;font-size:large">
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14.399999618530273px;vertical-align:baseline;clear:both;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:18px;background-color:rgba(248,248,248,0.6)">
Sorry for asking questions to just helping me debug my python script, but I really can't find where to be edited, and here's my script to generate new mapset,</p><pre style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:12px;vertical-align:baseline;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;background-color:rgb(238,238,238);color:rgb(57,51,24);word-wrap:normal;line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;color:rgb(34,34,34);white-space:inherit"><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">import</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> os
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">import</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> sys
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(134,134,134)">#set up GRASS environment variables</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
sys</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">path</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">append</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">os</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">path</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">join</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">os</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">environ</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">[</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'GISBASE'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">],</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'etc'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'python'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">))</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">import</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> grass</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">script </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">as</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> g
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">import</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> grass</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">script</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">setup </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">as</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> gsetup
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(134,134,134)">#create new mapset in the location</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
g</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">run_command</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'g.mapset'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'-c'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> mapset </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'watershed_analysis'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> location </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'newLocation'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">,</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> gisdb </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'C:\Users\Heinz\Documents\grassdata'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">)</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(134,134,134)">#check result</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">print</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> g</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">.</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">read_command</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">(</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'g.mapsets'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0)">'-l'</span><span style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">)</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14.399999618530273px;vertical-align:baseline;clear:both;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:18px;background-color:rgba(248,248,248,0.6)">
The script runs fine but with no output, what mistake did I make?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14.399999618530273px;vertical-align:baseline;clear:both;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:18px;background-color:rgba(248,248,248,0.6)">
I am using GRASS 6.4.3, python 2.7 under Windows 8.1</p></div></div>
<br></blockquote><div>How about:</div><div><br></div><div> g.run_command('g.mapset<span style="background-color:rgb(255,217,102)">', flags='c' ,</span> mapset = 'watershed_analysis', location = 'newLocation', gisdb = <span style="background-color:rgb(255,217,102)">r'</span>C:\Users\Heinz\Documents\grassdata')</div>
<div><br></div><div>print g.read_command('g.mapsets<span style="background-color:rgb(255,217,102)">', flags=</span>'l')<br></div><div><br></div><div><br></div><div>Anna</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br></blockquote></div><br></div></div>