<?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 Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10051#M869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have encountered a new problem. Consider the code snippet below. This code can be dropped into any Python Toolbox (*.pyt) in place of the execute() function. All it is doing is assigning a plain text string that contains a file path to an sde file on disk. The same value is assigned on two different lines. In the first case, the value is all in one string, while in the second case, it is broken apart.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either line works fine when running the tool in ArcGIS desktop. However, if I attempt to publish the result of the tool to ArcGIS server, ArcCatalog crashes completely, with presenting the dialog for reporting a problem. If that first line is excluded, and/or if the path does not match the location of an existing sde file, then publishing the will work fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 def execute(self, parameters, messages):
&amp;nbsp; 
&amp;nbsp; ### Declaring a text string that points to an existing *.sde file on the local
&amp;nbsp; ### disk will cause ArcCatalog to crash when attempting to publish
&amp;nbsp; ### a result from running this tool as a GP Service
&amp;nbsp; myGeodatabase = "C:/Data/test.sde"
&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp; ### The following approach seems to
&amp;nbsp; ### workaround this for now:
&amp;nbsp; myGeodatabase = "C:/Data/"+"test.sde"
&amp;nbsp; 
&amp;nbsp; return
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm guessing this may have something to do with the way that ArcGIS 10.1 keeps track of references to data on disk, and aligns these with databases/folders that are registered on a ArcGIS server that I'm publishing to. If that's the case, then I would imagine that the workaround I show is tricking the publishing service into overlooking the reference to the sde file. However, even if I have both the database connection and the folder that contains the sde file registered as data sources on the server, the publishing service will still crash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone else encountered this kind of problem, and/or is there something particularly wrong that I'm doing with this? Perhaps there is a better method to handle references to local data - would anyone have suggestions on that? It doesn't make sense in my case to have the location of the sde file exposed as a parameter in the GP tool, as client applications will not be aware of this...nor would I want clients to supply the location of a different sde file on the server.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 15:54:26 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-12T15:54:26Z</dc:date>
    <item>
      <title>Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10051#M869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have encountered a new problem. Consider the code snippet below. This code can be dropped into any Python Toolbox (*.pyt) in place of the execute() function. All it is doing is assigning a plain text string that contains a file path to an sde file on disk. The same value is assigned on two different lines. In the first case, the value is all in one string, while in the second case, it is broken apart.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either line works fine when running the tool in ArcGIS desktop. However, if I attempt to publish the result of the tool to ArcGIS server, ArcCatalog crashes completely, with presenting the dialog for reporting a problem. If that first line is excluded, and/or if the path does not match the location of an existing sde file, then publishing the will work fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 def execute(self, parameters, messages):
&amp;nbsp; 
&amp;nbsp; ### Declaring a text string that points to an existing *.sde file on the local
&amp;nbsp; ### disk will cause ArcCatalog to crash when attempting to publish
&amp;nbsp; ### a result from running this tool as a GP Service
&amp;nbsp; myGeodatabase = "C:/Data/test.sde"
&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp; ### The following approach seems to
&amp;nbsp; ### workaround this for now:
&amp;nbsp; myGeodatabase = "C:/Data/"+"test.sde"
&amp;nbsp; 
&amp;nbsp; return
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm guessing this may have something to do with the way that ArcGIS 10.1 keeps track of references to data on disk, and aligns these with databases/folders that are registered on a ArcGIS server that I'm publishing to. If that's the case, then I would imagine that the workaround I show is tricking the publishing service into overlooking the reference to the sde file. However, even if I have both the database connection and the folder that contains the sde file registered as data sources on the server, the publishing service will still crash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone else encountered this kind of problem, and/or is there something particularly wrong that I'm doing with this? Perhaps there is a better method to handle references to local data - would anyone have suggestions on that? It doesn't make sense in my case to have the location of the sde file exposed as a parameter in the GP tool, as client applications will not be aware of this...nor would I want clients to supply the location of a different sde file on the server.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:54:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10051#M869</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T15:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10052#M870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok - I've done some further testing...I can avoid adding the string to the Python code itself, by adding a Workspace parameter to my tool in the PYT toolbox. When this gets published, the Workspace parameter is treated as a 'constant' value, and doesn't get exposed to clients through the REST interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I still have a problem with the published GP tool getting file references rewritten to the wrong location. For example, here is my parameter as it is defined in the PYT toolbox:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; TestWorkspace= arcpy.Parameter(
&amp;nbsp;&amp;nbsp; displayName="TestWorkspace",
&amp;nbsp;&amp;nbsp; name="TestWorkspace",
&amp;nbsp;&amp;nbsp; datatype="Workspace",
&amp;nbsp;&amp;nbsp; parameterType="Required",
&amp;nbsp;&amp;nbsp; direction="Input")

&amp;nbsp; ### Cannot set a default value in code - this will
&amp;nbsp; ### crash ArcCatalog when the tool result is published:
&amp;nbsp; # TestWorkspace.value = "C:/Data/test.sde"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As noted in the comments, I cannot set the default value of the parameter in code - this will crash ArcCatalog when publishing the service. If I do not set the value of that parameter in the code, then run the tool in ArcGIS Desktop and point that paramter to the appropriate *.sde file, the geoprocessing result will publish fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I get now is that the path to the test.sde connection is being rewritten during the publishing process. If I set the geoprocessing tool's messaging level to 'Info', I will see the following error when I attempt to submit a job to the GPServer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
esriJobMessageTypeError: ERROR 000732: TestWorkspace: Dataset C:\Users\Administrator\AppData\Local\ESRI\Desktop10.1\Staging\arcgis on localhost_6080 (admin)\63\v101\test.sde does not exist or is not supported

#
 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The folder that contains the original sde file (C:/Data) and the geodatabase that the connection file points to are both registered as data stores on the server, so I don't know why the path to the sde connection file is being rewritten to point to a staging folder. Does anyone know what it is that I'm missing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10052#M870</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T15:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10053#M871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for reporting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can reproduce this and will get a bug logged for it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just on the quick testing I've done: it seems specific to executing this workflow in ArcCatalog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I do the same inside ArcMap it works fine - can you try your workflow there?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 15:41:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10053#M871</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2012-12-12T15:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10054#M872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Kevin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; You are correct, the first problem I note (ArcCatalog crashing) is not an issue if I publish using ArcMap instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However...I still get the problem I note in my second post - the paths to SDE connection are being rewritten to point to a staging folder, which will no longer exist after the service is published.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 16:01:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10054#M872</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-12-12T16:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10055#M873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When I publish from ArcMap, and go find the PTY in the Input directory, I have the following inside:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Esri start of added variables
import os, arcpy
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'ne2k864_DB_auth.sde')
# Esri end of added variables

#........
&amp;nbsp;&amp;nbsp;&amp;nbsp; def execute(self, parameters, messages):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """The source code of the tool."""
&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; wrkspc = g_ESRI_variable_1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is correct per the publishing process. My SDE connection file lives at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;c:\arcgisserver\directories\arcgissystem\arcgisinput\Tool.GPServer\extracted\v101&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The v101 folder &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;is&lt;/SPAN&gt;&lt;SPAN&gt; the packageworkspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you using 10.1 final or 10.1 sp1?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how you're getting the staging directory pushed into the PYT. Thats definitely wrong, but I can't reproduce that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Side note to your first point : a workspace isn't a supported input type with GP Services. We re-map that to constant (basically hardcode it). We do support "string", you could manually write that up. Without knowing your requirements, the only general statement is most of the time, workspaces arent necessary as a parameter visible to users. If any changes to the workspace need to be done, its best done behind the scenes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have a full PYT you could share (just so I can get a better idea what you're doing)? If you dont want to post here, you can email it to me: &lt;/SPAN&gt;&lt;A href="mailto:khibma@esri.com" rel="nofollow noopener noreferrer" target="_blank"&gt;khibma@esri.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10055#M873</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2021-12-10T20:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10056#M874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Kevin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like the root of the problem is the presence/absence of the unicode 'u' modifier on the strings.&amp;nbsp; If I include that, I can set a variable to u"C:/Data/test.sde" or os.path.join(u"C:/Data",u"test.sde"), and publish fine with ArcMap (ArcCatalog still crashes).&amp;nbsp; If I leave out the 'u' character, ArcMap will crash just as badly as ArcCatalog when I attempt to publish the result.&amp;nbsp; After publishing successfully, I also find that path to the sde connection file gets translated to a location on the server, such as "C:\arcgisserver\directories\arcgissystem\arcgisinput\VGO\Test.GPServer\extracted\v101\test.sde"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been doing this testing in ArcGIS 10.1 SP1, and I hadn't posted a complete toolbox previously, since all that is needed to demonstrate the problem in my environment is a couple lines of code in the execute function .&amp;nbsp; However, an example of what I'm currently testing is attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, aside from the bug that affects ArcCatalog, should I have known that I need to use unicode strings for this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still find that other strings get caught unexpectedly.&amp;nbsp; For example, I might want to save a prefix for feature class names that will be used when accessing them from the geodatabase.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

myGeodatabase = os.path.join(u"C:/Data","test.sde")

featureClassPrefix = u"/test.sde."&amp;nbsp; ### Sometimes this will get replaced with a path that points to the staging folder...sometimes ArcMap crashes entirely...sometimes it's left untouched.

pointFeatureClass = myGeodatabse+featureClassPrefix+u"TestPoints"

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not able to consistently produce the same problem, but basically, I have to be very careful that I don't specify any string values that may be interpreted as a connection file.&amp;nbsp; If I substitute u'/test.sde' with u'/'+u'test.sde', the problem goes away.&amp;nbsp; Or if I rename the connection file so that it is not the same name as the underlying database (e.g., name the file test_default.sde), then the problem also will go away in that scenario.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It might be worth noting also that the connection file and the pyt file are in the same folder on the disk.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10056#M874</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T20:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10057#M875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I dont think I have all the answers to your questions, but I can say this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When writing paths, you don't need the 'u'. (as long as they're written correctly - correctly being forward slash or double backslash or done with 'u' or 'r')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you're building up paths I &lt;/SPAN&gt;&lt;STRONG&gt;strongly&lt;/STRONG&gt;&lt;SPAN&gt; encourage you to use the os.path.join function and &lt;/SPAN&gt;&lt;STRONG&gt;never&lt;/STRONG&gt;&lt;SPAN&gt; the "+" to add up paths. I cannot guarantee that when scanning your script for required data for publishing/packaging that strings (paths) built up with + will be caught. We can and do work quite well with os.path.join&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if you've seen this help topic, if not I'd give a quick read:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The short of it: if we encounter project data in your script, we evaluate that against the datastore to either copy or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; import os
&amp;gt;&amp;gt;&amp;gt; start = "sde.sde"
&amp;gt;&amp;gt;&amp;gt; end = ".fc1"
&amp;gt;&amp;gt;&amp;gt; sdeServer = "c:/mydata/somesde.sde"
&amp;gt;&amp;gt;&amp;gt; print os.path.join(sdeServer, start + end)
c:/mydata/somesde.sde\sde.sde.fc1
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if you start mixing in slashes with your strings, you'll see what happens when they get put together with os.path.join&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; start2 = "/test.sde"
&amp;gt;&amp;gt;&amp;gt; print os.path.join(sdeServer, start2 + end)
/test.sde.fc1&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This stackexchange answer describes what slashes do inside an os.path.join statement : &lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/1945920/os-path-join-python" rel="nofollow noopener noreferrer" target="_blank"&gt;http://stackoverflow.com/questions/1945920/os-path-join-python&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;So anytime that slash is encountered in os.path.join, its like resetting the path. Does this clear it up at all?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regardless of all this, it shouldn't crash : I assigned the bug to a developer and we'll evaluate for 10.1.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(NIM087309 - Publishing or sharing a PYT from ArcCatalog causes a crash when referencing a .SDE workspace)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for including your workflow. I'll take a look to make sure we're catching everything.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10057#M875</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2021-12-10T20:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10058#M876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We've debugged this down further and think we have an understanding of the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you still have a version of your toolbox before hacking it up to get around this problem, you can try this which should probably work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcCatalog, goto Geoprocessing &amp;gt; Environments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set a value for the Current Workspace (under the Workspace heading)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can set this to a folder or a fGDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now when publishing or packaging it should work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, my apologies for the inconvenience. We're working on a fix that you'll hopefully see in service pack 2.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 16:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10058#M876</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2012-12-13T16:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10059#M877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've got another dimension to add to this.&amp;nbsp; If I have just a plain string that I'm using to split a string with slashes, it gets interpreted as a reference to the entire hard drive:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import mimetypes
mtype = mimetypes.guess_type(filename)[0].split("/")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I comment out the code with with the slash, the service will publish fine.&amp;nbsp; This is in ArcMap, with a default gdb set in the environment settings.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10059#M877</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T20:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing PYT with a string pointing to an SDE file on disk crashes ArcCatalog</title>
      <link>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10060#M878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For anyone else that comes across this thread with a similar problem, the following solution was suggested to me for splitting a string with slash characters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import mimetypes
mtype = os.path.split(mimetypes.guess_type(filename)[0])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:25:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-pyt-with-a-string-pointing-to-an-sde/m-p/10060#M878</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T20:25:25Z</dc:date>
    </item>
  </channel>
</rss>

