<?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 automatic logon to the gis() in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859327#M4144</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI, I am looking for the best practice way to make my script run&amp;nbsp;in ArcGIS Pro and Exterprise&amp;nbsp;portal without modification - specifically getting the gis().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The user will be already logged in and have an active portal before running the script.&lt;/P&gt;&lt;P&gt;At the moment I use gis("home") when using portal and gis("Pro") when using Arc Pro&lt;/P&gt;&lt;P&gt;is there a test I can use to determine whether the script is running in in Pro or Portal so I can choose?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, is there a different approach I should be using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Sep 2020 07:23:57 GMT</pubDate>
    <dc:creator>IanHamilton2</dc:creator>
    <dc:date>2020-09-14T07:23:57Z</dc:date>
    <item>
      <title>automatic logon to the gis()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859327#M4144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI, I am looking for the best practice way to make my script run&amp;nbsp;in ArcGIS Pro and Exterprise&amp;nbsp;portal without modification - specifically getting the gis().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The user will be already logged in and have an active portal before running the script.&lt;/P&gt;&lt;P&gt;At the moment I use gis("home") when using portal and gis("Pro") when using Arc Pro&lt;/P&gt;&lt;P&gt;is there a test I can use to determine whether the script is running in in Pro or Portal so I can choose?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, is there a different approach I should be using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2020 07:23:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859327#M4144</guid>
      <dc:creator>IanHamilton2</dc:creator>
      <dc:date>2020-09-14T07:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: automatic logon to the gis()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859328#M4145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/332336"&gt;Ian Hamilton&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;You can rename your scripts.&lt;/P&gt;&lt;P&gt;e.g. pro_script.py&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;portal_script.py&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2020 08:17:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859328#M4145</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2020-09-14T08:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: automatic logon to the gis()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859329#M4146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this could work by putting the two login methods in a try-except statement.&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# first attempt to login using notebook specific home&lt;/SPAN&gt;
    gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"home"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# otherwise login using active portal in pro&lt;/SPAN&gt;
    gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"pro"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm pretty sure running GIS("home") outside of ArcGIS Notebooks will throw up an error, allowing this switch to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859329#M4146</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2021-12-12T10:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: automatic logon to the gis()</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859330#M4147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I'll give this a go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2020 23:28:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/automatic-logon-to-the-gis/m-p/859330#M4147</guid>
      <dc:creator>IanHamilton2</dc:creator>
      <dc:date>2020-09-14T23:28:27Z</dc:date>
    </item>
  </channel>
</rss>

