<?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: Work Around for os.startfile Crashing arcmap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279425#M21595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Todd, &lt;/P&gt;&lt;P&gt;Google Earth, the file actually opens when my addin is run, it just crashes arcmap in the process of doing so. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2015 15:17:14 GMT</pubDate>
    <dc:creator>BenjaminMittler</dc:creator>
    <dc:date>2015-06-05T15:17:14Z</dc:date>
    <item>
      <title>Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279423#M21593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently attempting to develop an addin that creates a KML from a layer within arcmap, and then opens that KML. All seems to be going well except that every time the tool runs it crashes arcmap. I am aware that this is because i am using the "os.startfile()" command. What possible workaround can i use to get this file to open at the end of my script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Not a python expert by any means&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:38:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279423#M21593</guid>
      <dc:creator>BenjaminMittler</dc:creator>
      <dc:date>2015-06-05T14:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279424#M21594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you want to open the KML in your current MXD in ArcMap? Or using an outside program like Google Earth?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:56:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279424#M21594</guid>
      <dc:creator>ToddBlanchette</dc:creator>
      <dc:date>2015-06-05T14:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279425#M21595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Todd, &lt;/P&gt;&lt;P&gt;Google Earth, the file actually opens when my addin is run, it just crashes arcmap in the process of doing so. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:17:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279425#M21595</guid>
      <dc:creator>BenjaminMittler</dc:creator>
      <dc:date>2015-06-05T15:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279426#M21596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for more info.&amp;nbsp; If you're using Windows, os.startfile() shouldn't be giving you any issues, and like you said, it starts Google Earth fine (if kml/kmz is associated with that program within windows as the default program).&amp;nbsp; Is there anything else in your code after the os.startfile() is called?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:36:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279426#M21596</guid>
      <dc:creator>ToddBlanchette</dc:creator>
      <dc:date>2015-06-05T15:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279427#M21597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason Schriener at ESRI got this work around for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add this def:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def run_in_other_thread(function): #conflicts w/ os.startfile will crash arcmap.&amp;nbsp; this is a workaround&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # functool.wraps will copy over the docstring and some other metadata&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # from the original function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @functools.wraps(function)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def fn_(*args, **kwargs):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thread = threading.Thread(target=function, args=args, kwargs=kwargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thread.start()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thread.join()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startfile = run_in_other_thread(os.startfile)&lt;/P&gt;&lt;P&gt;startfile(theFilePath)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:40:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279427#M21597</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2015-06-05T15:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Work Around for os.startfile Crashing arcmap</title>
      <link>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279428#M21598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Kevin, worked like a charm. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually came across the thread with this information while researching the problem and it ended up that i was just calling it wrong. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all others running into this error in the future this seems to be the workaround.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:56:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/work-around-for-os-startfile-crashing-arcmap/m-p/279428#M21598</guid>
      <dc:creator>BenjaminMittler</dc:creator>
      <dc:date>2015-06-05T15:56:58Z</dc:date>
    </item>
  </channel>
</rss>

