<?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: Exit not allowing script to show in Pro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078676#M61738</link>
    <description>&lt;P&gt;Not sure this will work, but have you tried wrapping the json_in process into a try/except and in the except block log the debug message and exit?&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 14:00:24 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-07-14T14:00:24Z</dc:date>
    <item>
      <title>Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078645#M61733</link>
      <description>&lt;P&gt;I have a python script added to a toolbox in ArcGIS Pro 2.8. I need to terminate early if certain conditions are met but I need the script to complete successfully and not error. I am trying to use sys.exit(0) and it says the script run succeeded in messages. However the History pane is showing it as a Red ! as if it failed which is blocking me from publishing as a web tool. Is there a better way to exit early?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 13:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078645#M61733</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-07-14T13:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078652#M61734</link>
      <description>&lt;P&gt;Could you provide the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 13:26:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078652#M61734</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-14T13:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078655#M61735</link>
      <description>&lt;P&gt;Here is that specific part as the entire code is rather large. What I am trying to do is create a tool that will be published but I do not want people seeing the syntax used for the input. So I need the tool to successfully run by using some placeholder text rather than valid json the tool would need to fully execute.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def execute(self, parameters, messages):
        """The source code of the tool."""
        # setting up needed pieces
        messages = []
        contact_lists = []
        email_list = []

        # setting up logging
        LOG_FILENAME = sys.path[0] + "\\logging_AmicaGP." + dt.now().strftime("%Y%m%d%H%M%S%f") + ".txt"
        logging.basicConfig(filename=LOG_FILENAME, format='%(asctime)s %(levelname)s %(message)s', level=10)
        with open(LOG_FILENAME, 'w'):
            pass
        arcpy.AddMessage("log file: " + LOG_FILENAME)
        logging.debug('This is a LOG file for AMICA GP tool')        
        arcpy.Delete_management("in_memory")
        
        json_in = parameters[0].valueAsText
        if json_in == 'Input Feature':
            logging.debug('Setting up discrete input for publishing purposes')
                       
            sys.exit(0)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 13:32:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078655#M61735</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-07-14T13:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078676#M61738</link>
      <description>&lt;P&gt;Not sure this will work, but have you tried wrapping the json_in process into a try/except and in the except block log the debug message and exit?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:00:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078676#M61738</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-14T14:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078683#M61742</link>
      <description>&lt;P&gt;Instead of sys.exit() can you&amp;nbsp; try quit() ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import time 
for x in range(0,10):
    if x == 9:
        print(f'{x} Quit in 5 seconds')
        time.sleep(5)
        quit()&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078683#M61742</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-07-14T14:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078696#M61746</link>
      <description>&lt;P&gt;Quit() is giving me the same result as sys.Exit()&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078696#M61746</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-07-14T14:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Exit not allowing script to show in Pro</title>
      <link>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078697#M61747</link>
      <description>&lt;P&gt;I just figured it out. I was able to just use return to move me back to def main.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
def main():
    tbx = Toolbox()
    tool = ExposureTool()
    tool.execute(tool.getParameterInfo(),None)

if __name__ == '__main__':
	main()
"""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 14:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exit-not-allowing-script-to-show-in-pro/m-p/1078697#M61747</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2021-07-14T14:26:48Z</dc:date>
    </item>
  </channel>
</rss>

