Python Gurus,
I have downloaded the Spatial Analyst Supplemental Tools which is a Python Toolbox and there appears to be a bug in the Peak tool. I know a little bit of Python and thought I would have a crack at debugging it, primarily to teach myself how to use a Python toolbox. I am use to creating python script tools but not a Python toolbox.
Anyway every time I tweak the code in the Peak tool and try to run it, it's as if the tool has been cached and none of my tweaks run. I looked at help and found this page and in the tip section it talks about imported modules needing reloading. I think this is my problem none of my changes are being refreshed. But the import statement is "from peaktool import Peak". If I type reload(peaktool) it says "name 'peaktool' is not defined". So the help page gives advice but does not explicity show you how to do it!
So my question is how do you reload a module when the importing of it is in the format of "from peaktool import Peak" and where would one put the reload statement in the code? Below is the Python toolbox code.
<SPAN class="keyword token">import</SPAN> sys
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> arcpy
myScripts <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>dirname<SPAN class="punctuation token">(</SPAN>__file__<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Scripts"</SPAN><SPAN class="punctuation token">)</SPAN>
sys<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>myScripts<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">from</SPAN> dendrogrampdf <SPAN class="keyword token">import</SPAN> CreateDendrogram
<SPAN class="keyword token">from</SPAN> viewshedalongpath <SPAN class="keyword token">import</SPAN> ViewshedAlongPath
<SPAN class="keyword token">from</SPAN> maxelevation <SPAN class="keyword token">import</SPAN> MaximumUpstreamElevation
<SPAN class="keyword token">from</SPAN> drawsig <SPAN class="keyword token">import</SPAN> DrawSignatures
<SPAN class="keyword token">from</SPAN> filledcontours <SPAN class="keyword token">import</SPAN> FilledContours
<SPAN class="keyword token">from</SPAN> peaktool <SPAN class="keyword token">import</SPAN> Peak
<SPAN class="keyword token">from</SPAN> eraserastervalues <SPAN class="keyword token">import</SPAN> EraseRasterValues
<SPAN class="keyword token">from</SPAN> zonalstatisticsastable02 <SPAN class="keyword token">import</SPAN> ZonalStatisticsAsTable02
<SPAN class="keyword token">from</SPAN> tabulatearea02 <SPAN class="keyword token">import</SPAN> TabulateArea02
<SPAN class="keyword token">class</SPAN> <SPAN class="token class-name">Toolbox</SPAN><SPAN class="punctuation token">(</SPAN>object<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">__init__</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="string token">"""Define the toolbox (the name of the toolbox is the name of the .pyt file)."""</SPAN>
self<SPAN class="punctuation token">.</SPAN>label <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Spatial Analyst Supplemental Tools"</SPAN>
self<SPAN class="punctuation token">.</SPAN>alias <SPAN class="operator token">=</SPAN> <SPAN class="string token">"sas"</SPAN>
<SPAN class="comment token"># List of tool classes associated with this toolbox </SPAN>
self<SPAN class="punctuation token">.</SPAN>tools <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>CreateDendrogram<SPAN class="punctuation token">,</SPAN> DrawSignatures<SPAN class="punctuation token">,</SPAN> ViewshedAlongPath<SPAN class="punctuation token">,</SPAN>MaximumUpstreamElevation<SPAN class="punctuation token">,</SPAN> FilledContours<SPAN class="punctuation token">,</SPAN> Peak<SPAN class="punctuation token">,</SPAN> EraseRasterValues<SPAN class="punctuation token">,</SPAN>ZonalStatisticsAsTable02<SPAN class="punctuation token">,</SPAN>TabulateArea02<SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Peak is a Class in the peaktools module.