<?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 Configure Notebook connection info to support use with both Online and Pro? in ArcGIS Notebooks Questions</title>
    <link>https://community.esri.com/t5/arcgis-notebooks-questions/configure-notebook-connection-info-to-support-use/m-p/506703#M154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there an environment parameter or attribute that can be accessed&amp;nbsp;from within a Notebook in order to reliably determine if it is being run in ArcGIS Online or in ArcGIS Pro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are finding that we often have Notebooks we want to use in both environments. Rather than having to edit the GIS connection info depending on where it is being run, we would like it to figure&amp;nbsp;that out on&amp;nbsp;its own.&amp;nbsp; If it is running in Pro, then use &lt;SPAN style="font-family: 'andale mono', monospace;"&gt;GIS('pro')&lt;/SPAN&gt;, and&amp;nbsp;if it is running in ArcGIS Online, then use &lt;SPAN style="font-family: 'andale mono', monospace;"&gt;GIS('home')&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For now, we are&amp;nbsp;making that assumption that&amp;nbsp;the Notebook environment's HOMEPATH is r'/home/arcgis' when it is being run in ArcGIS Online. If is being run in ArcGIS Pro, then it will have some other value; it being highly unlikely that someone has installed it on their own machine in "/home/arcgis", especially on a Windows machine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;homepath = %env HOMEPATH&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;if( homepath == r'/home/arcgis' &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; print( "ArcGIS Online Notebook" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; gis = GIS('home')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; print( "Local Notebook" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; gis = GIS('pro')&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be nice to have something that is well-known and authoritative to use instead though, so&amp;nbsp;that we could rely on it in&amp;nbsp;the long-run.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 May 2020 18:23:30 GMT</pubDate>
    <dc:creator>PeterKnoop</dc:creator>
    <dc:date>2020-05-21T18:23:30Z</dc:date>
    <item>
      <title>Configure Notebook connection info to support use with both Online and Pro?</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/configure-notebook-connection-info-to-support-use/m-p/506703#M154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there an environment parameter or attribute that can be accessed&amp;nbsp;from within a Notebook in order to reliably determine if it is being run in ArcGIS Online or in ArcGIS Pro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are finding that we often have Notebooks we want to use in both environments. Rather than having to edit the GIS connection info depending on where it is being run, we would like it to figure&amp;nbsp;that out on&amp;nbsp;its own.&amp;nbsp; If it is running in Pro, then use &lt;SPAN style="font-family: 'andale mono', monospace;"&gt;GIS('pro')&lt;/SPAN&gt;, and&amp;nbsp;if it is running in ArcGIS Online, then use &lt;SPAN style="font-family: 'andale mono', monospace;"&gt;GIS('home')&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For now, we are&amp;nbsp;making that assumption that&amp;nbsp;the Notebook environment's HOMEPATH is r'/home/arcgis' when it is being run in ArcGIS Online. If is being run in ArcGIS Pro, then it will have some other value; it being highly unlikely that someone has installed it on their own machine in "/home/arcgis", especially on a Windows machine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;homepath = %env HOMEPATH&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;if( homepath == r'/home/arcgis' &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; print( "ArcGIS Online Notebook" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; gis = GIS('home')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; print( "Local Notebook" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; gis = GIS('pro')&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be nice to have something that is well-known and authoritative to use instead though, so&amp;nbsp;that we could rely on it in&amp;nbsp;the long-run.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2020 18:23:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/configure-notebook-connection-info-to-support-use/m-p/506703#M154</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2020-05-21T18:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Configure Notebook connection info to support use with both Online and Pro?</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/configure-notebook-connection-info-to-support-use/m-p/506704#M155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A&amp;nbsp;recent release of ArcGIS Online switched to using a different environment variable, HOME, instead of HOMEPATH.&amp;nbsp;And, HOMEPATH is no longer&amp;nbsp;present&amp;nbsp;in the ArcGIS Online Notebook environment, while&amp;nbsp;HOME&amp;nbsp;may not be present in a standalone ArcGIS API for Python environment (as of 1.8.2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a quickly updated version of the generic login snippet to accommodate those changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;# Obtain the value of HOME, if it exists in the environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;if( "HOME" in os.environ):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;homepath = %env HOME&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;homepath = ""&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;# If HOME is set to /home/arcgis, then assume the environment is ArcGIS Online.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;if( homepath == r'/home/arcgis' &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;print( "ArcGIS Online Notebook Server" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;gis = GIS('home')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;print( "Local Notebook Server" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;gis = GIS('pro')&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:49:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/configure-notebook-connection-info-to-support-use/m-p/506704#M155</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2020-11-02T13:49:23Z</dc:date>
    </item>
  </channel>
</rss>

