<?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: Why does the below script fail when custom toolbox is stored on an enterprise geodatabase? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119244#M9389</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Blake. Your post was very helpful and i have applied the python formatting. The code should now be readable and clear.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Mar 2015 22:22:56 GMT</pubDate>
    <dc:creator>DavidMuthami1</dc:creator>
    <dc:date>2015-03-18T22:22:56Z</dc:date>
    <item>
      <title>Why does the below script fail when custom toolbox is stored on an enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119242#M9387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#-------------------------------------------------------------------------------
# Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ULIMS Perfomance Management
# Purpose:&amp;nbsp;&amp;nbsp;&amp;nbsp; Script scheduled in windows scheduler used to perfom enteprise geodatabase tuning
#
# Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dmuthami
#
# Created:&amp;nbsp;&amp;nbsp;&amp;nbsp; 17/03/2015
# Copyright:&amp;nbsp; (c) dmuthami 2015
# Licence:&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;your licence&amp;gt;
#-------------------------------------------------------------------------------
import os, sys
import logging
import arcpy
import traceback
from arcpy import env
from datetime import datetime




def ulimsPerfomanceManagement():
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set-up logging
&amp;nbsp;&amp;nbsp;&amp;nbsp; logger = logging.getLogger('ulimsAutomation')
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Export to text file#
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentDate = datetime.now().strftime("-%y-%m-%d_%H-%M-%S") # Current time
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set-up some error logging code.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cat_logfile = os.path.join(os.path.dirname("__file__"), 'cat_logfile' + str(currentDate)+'.log')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #cat_logfile = r"C:\DAVID-MUTHAMI\GIS Data\Namibia ULIMS\Scripts" + "\\"+str(currentDate)+'.log'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hdlr = logging.FileHandler(cat_logfile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hdlr.setFormatter(formatter)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.addHandler(hdlr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.setLevel(logging.INFO)




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Import the toolbox containing the model.&amp;nbsp; This toolbox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; has an alias of "ulimsAutomation"




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Run model in a toolbox in a folder
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # model optimizes enterprise geodatabase from SQL Server
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.ImportToolbox(r"C:\DAVID-MUTHAMI\GIS Data\Namibia ULIMS\Scripts\ULIMS_System.tbx","ulimsAutomation")




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Run model hosted on SQL Server enterprise GDB to optimize enterprise geodatabase
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportToolbox(r"Database Connections\sde@localhost@ulims_publication.sde","ulimsAutomation")




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run the model.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ULIMSPerformanceManagement_ulimsAutomation()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg = "Performance tuning complete"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print msg
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.info(msg)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Return any Python specific errors and any error returned by the geoprocessor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\n ulimsPerfomanceManagement() Function : Traceback Info:\n" + tbinfo + "\nError Info:\n&amp;nbsp;&amp;nbsp;&amp;nbsp; " + \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n" +\
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Line {0}".format(tb.tb_lineno)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "Geoprocessing&amp;nbsp; Errors :\n" + arcpy.GetMessages(2) + "\n"




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##Add custom informative message to the Python script tool
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg) #Add error message to the Python script tool(Progress dialog box, Results windows and Python Window).
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp; #Add error message to the Python script tool(Progress dialog box, Results windows and Python Window).




&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##For debugging purposes only
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##To be commented on python script scheduling in Windows _log
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.info(pymsg)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "\n" +msgs
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.info(msgs)




def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass




if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Run perfomance management module
&amp;nbsp;&amp;nbsp;&amp;nbsp; ulimsPerfomanceManagement()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:58:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119242#M9387</guid>
      <dc:creator>DavidMuthami1</dc:creator>
      <dc:date>2021-12-11T06:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the below script fail when custom toolbox is stored on an enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119243#M9388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Psst! Posting your code with syntax highlighting is appreciated! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 21:33:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119243#M9388</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-18T21:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the below script fail when custom toolbox is stored on an enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119244#M9389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Blake. Your post was very helpful and i have applied the python formatting. The code should now be readable and clear.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 22:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119244#M9389</guid>
      <dc:creator>DavidMuthami1</dc:creator>
      <dc:date>2015-03-18T22:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the below script fail when custom toolbox is stored on an enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119245#M9390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Line 53 is the cause of the error. however, if i comment line 53 and uncomment line 47 the script runs flawlessly. This implies the problem occurs when when the model is stored in the enterprise geodatabase or any type of geodatabase used by Esri. The code only works if the model is in a toolbox stored in a folder. Let me if their is a solution. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Mar 2015 19:50:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119245#M9390</guid>
      <dc:creator>DavidMuthami1</dc:creator>
      <dc:date>2015-03-22T19:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the below script fail when custom toolbox is stored on an enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119246#M9391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to Esri support for providing answer to the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached full code with correction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erroneous line of code reads like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;arcpy.ImportToolbox(r&lt;/SPAN&gt;&lt;SPAN class="string" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: blue;"&gt;"Database Connections\sde@localhost@ulims_publication.sde"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: blue;"&gt;"ulimsAutomation"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Corrected line of code reads:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##The below line code is when the toolbox containing the model is stored/hosted on SQL Server enterprise GDB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportToolbox(r"D:\GIS\Connection Files\Live Site\sde@172.24.0.47@ulims_gis.sde\ulims_gis.SDE.System_Admin","ulimsAutomation")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2015 13:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-does-the-below-script-fail-when-custom-toolbox/m-p/119246#M9391</guid>
      <dc:creator>DavidMuthami1</dc:creator>
      <dc:date>2015-04-01T13:01:50Z</dc:date>
    </item>
  </channel>
</rss>

