kmz creates temporary directory

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

kmz creates temporary directory

Post by joleenf »

Hi,

I am saving files as kmz files using the scripting API. I noticed that this seems to be creating temporary directories in my McIDAS-V home directory <HOME>/McIDAS-V/tmp.

When I save through the GUI, I am seeing png files being placed in the temporary directory. These are filling up a /home directory on a shared machine because I am generating kmz files for the web.

(I forgot to update McV, so I am currently using the 2018-09-10 build on my Mac and Linux box.).

Thanks,
Joleen
User avatar
bobc
Posts: 938
Joined: Mon Nov 15, 2010 5:57 pm

Re: kmz creates temporary directory

Post by bobc »

Hi Joleen,

Thanks for bringing this to our attention. I'm replicating that these directories in the McIDAS-V/tmp directory aren't being cleared out. I wrote up Inquiry 2726 to investigate a better way of cleaning this /tmp directory. In the meantime, I wrote up the following script:

Code: Select all

# get path to McIDAS-V/tmp directory
tmpDir = '%s/tmp' % os.environ['MCV_USERPATH']
# get a listing of files
inDir = os.listdir(tmpDir)

# set up empty list for files/dirs
tmpList = []

# loop through files/dirs in tmpDir directory and add
# only those beginning with 'tmpdir' to tmpList above
for x in inDir:
    if str(x[0:6]) == 'tmpdir':
        tmpList.append(x)
    else:
        pass

# notify user of directories being removed:
print 'Removing directories:'
for x in tmpList:
    print x

# loop through items in tmpList list and remove them
# shutil.rmtree is used to remove directory and contents
for x in tmpList:
    shutil.rmtree('%s/%s' % (tmpDir, x))

There are comments throughout, but basically this script removes anything in your McIDAS-V/tmp directory whose first six characters are "tmpdir", which is what these directories are called on my Windows 7 machine. Until Inquiry 2726 is investigated, perhaps you could add something like the above lines to your scripts to clean the /tmp directory? If this doesn't seem like a reasonable workaround, please let me know.

Thanks,
Bob
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: kmz creates temporary directory

Post by joleenf »

Bob,

I am pretty sure I can work with you solution until the inquiry is addressed.

Thanks,
Joleen
Post Reply