<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python called from batch file --&amp;gt; geoprocessing logs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-called-from-batch-file-amp-gt-geoprocessing/m-p/720331#M55779</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just create my own .log file and write lines where needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#oLoc is just a network path string variable where I want to save this
#strD1 and strD2 are just variables of dates set previously

logpath = oLoc + "\\" + strD1 + "_to_" + strD2 + ".log"
logfile = open(logpath, 'w')
logfile.write("Log begin: " + str(log_startdate) + "\n")

#here is an example of how I am writting errors to the log file
# see if spatial analyst extension is available for use
availability = gp.CheckExtension("Spatial")
if availability=="Available":
&amp;nbsp;&amp;nbsp; gp.CheckOutExtension("Spatial")
else:
&amp;nbsp;&amp;nbsp; logfile.write("ERROR: Spatial Analyst extension not available" + "\n")
&amp;nbsp;&amp;nbsp; return


logfile.close()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:49:18 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2021-12-12T06:49:18Z</dc:date>
    <item>
      <title>Python called from batch file --&amp;gt; geoprocessing logs</title>
      <link>https://community.esri.com/t5/python-questions/python-called-from-batch-file-amp-gt-geoprocessing/m-p/720330#M55778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am calling a number of Python scripts from a batch file like below (simplified)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]SET PATH=%PATH%;D:\apps\Python27\ArcGIS10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SET PYSCRIPT="D:\Projects\MyTestScript.py"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;python %PYSCRIPT%[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and would like to benefit from the geoprocessing logging capabilities so that all messages written by arcpy.AddMessage() in the python scripts can be viewed later on from the ArcCatalog Geoprocessing &amp;gt; Results window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have added the following statements in the beginning of my Python scripts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetLogHistory(True)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.logHistory = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but that doesn't seem to have any effect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the only way to save the geocompressing logging if you execute the scripts actually from a tool within the ArcCatalog environment?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any suggestions,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Joep&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 13:24:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-called-from-batch-file-amp-gt-geoprocessing/m-p/720330#M55778</guid>
      <dc:creator>JoepLuijten</dc:creator>
      <dc:date>2013-01-24T13:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python called from batch file --&gt; geoprocessing logs</title>
      <link>https://community.esri.com/t5/python-questions/python-called-from-batch-file-amp-gt-geoprocessing/m-p/720331#M55779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just create my own .log file and write lines where needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#oLoc is just a network path string variable where I want to save this
#strD1 and strD2 are just variables of dates set previously

logpath = oLoc + "\\" + strD1 + "_to_" + strD2 + ".log"
logfile = open(logpath, 'w')
logfile.write("Log begin: " + str(log_startdate) + "\n")

#here is an example of how I am writting errors to the log file
# see if spatial analyst extension is available for use
availability = gp.CheckExtension("Spatial")
if availability=="Available":
&amp;nbsp;&amp;nbsp; gp.CheckOutExtension("Spatial")
else:
&amp;nbsp;&amp;nbsp; logfile.write("ERROR: Spatial Analyst extension not available" + "\n")
&amp;nbsp;&amp;nbsp; return


logfile.close()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-called-from-batch-file-amp-gt-geoprocessing/m-p/720331#M55779</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T06:49:18Z</dc:date>
    </item>
  </channel>
</rss>

