<?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: Managing Temp files when using arcpy.mp.ArcGISProject in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/managing-temp-files-when-using-arcpy-mp/m-p/1485354#M70725</link>
    <description>&lt;P&gt;Python has a builtin tempfile module that you can use to make a tempfile then use shutil.rmtree when you're done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import shutil
import tempfile
import os

def mk_tempdir(location: os.PathLike = None):
    fd, temp_file_name = tempfile.mkdtemp(dir=location)
    return temp_file_name

def del_tempdir(temp_file_name: os.PathLike):
    shutil.rmtree(temp_file_name)
    return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2024 13:32:05 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2024-06-05T13:32:05Z</dc:date>
    <item>
      <title>Managing Temp files when using arcpy.mp.ArcGISProject</title>
      <link>https://community.esri.com/t5/python-questions/managing-temp-files-when-using-arcpy-mp/m-p/1478194#M70652</link>
      <description>&lt;P&gt;I have a Python script that uses ArcPy to open an ArcGIS Pro Project and export pages of a Map Series to PDF files.&lt;/P&gt;&lt;P&gt;The Map used by the Map Series contains 2 WMS layers and some other SDE layers.&lt;/P&gt;&lt;P&gt;It's running successfully but I am trying to manage the temporary files that are being generated. As the Map Series can be hundreds of pages and the WMS services generate many large png files, I have found that the Temp directory ArcGIS Pro uses is filling the disk to 100%.&lt;/P&gt;&lt;P&gt;When ArcGIS Pro is opened via desktop, the Temp directory gets created by default in C:\Users\&amp;lt;username&amp;gt;\AppData\Local\Temp\ArcGISProTemp&amp;lt;random number&amp;gt;.&lt;BR /&gt;When ArcGIS Pro is closed this directory is deleted.&lt;/P&gt;&lt;P&gt;When I run my script, the Temp directory used is just: C:\Users\&amp;lt;username&amp;gt;\AppData\Local\Temp (no extra folder is created) and any files generated by the script do not get deleted when the script ends.&lt;/P&gt;&lt;P&gt;I tried changing the location of the Temp directory to a disk with more space by setting the environment variable ARCTMPDIR. This worked using ArcGIS Pro desktop but when I ran my code it still&lt;BR /&gt;used C:\Users\&amp;lt;username&amp;gt;\AppData\Local\Temp.&lt;/P&gt;&lt;P&gt;So, is it possible to set the location of this Temp directory using Python, and therefore clean it up as I go? Ideally after each page of the Map Series has finished exporting.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 07:40:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/managing-temp-files-when-using-arcpy-mp/m-p/1478194#M70652</guid>
      <dc:creator>JasonBatory</dc:creator>
      <dc:date>2024-05-24T07:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Managing Temp files when using arcpy.mp.ArcGISProject</title>
      <link>https://community.esri.com/t5/python-questions/managing-temp-files-when-using-arcpy-mp/m-p/1485354#M70725</link>
      <description>&lt;P&gt;Python has a builtin tempfile module that you can use to make a tempfile then use shutil.rmtree when you're done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import shutil
import tempfile
import os

def mk_tempdir(location: os.PathLike = None):
    fd, temp_file_name = tempfile.mkdtemp(dir=location)
    return temp_file_name

def del_tempdir(temp_file_name: os.PathLike):
    shutil.rmtree(temp_file_name)
    return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 13:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/managing-temp-files-when-using-arcpy-mp/m-p/1485354#M70725</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-06-05T13:32:05Z</dc:date>
    </item>
  </channel>
</rss>

