• General
  • How to use a plugin on a bunch of iolite session files at once?

I'm hoping someone with a bit more experience using iolite 4 and APIs might be able to help me.

I have a folder of around 200 iolite session files. These files were processed by someone else previously.

I wrote a UI plugin to alter some things about the files, specifically the selections. The plugin in works great, I can use it just fine when I open one of those session files and it does what I want.

I'm hoping to find a way to automate running that plugin/the code from that plugin on all 200 iolite session files at once. Any advice would be amazing!

Thanks!

  • Joe replied to this.
    6 days later

    charlottebakalar

    I think the easiest way would be to use iolite's command line features to run a refactored version of your python script from an external script. The external script (whether written in python itself, powershell, bash, ...) would iterate through the files in your folder and call iolite with command line arguments that'll load the data and run your python script. Something like (with a lot of the details missing):

    import subprocess
    
    script = '''
    data.importData(r'$file')
    # Do all your stuff to adjust selections...
    data.saveSession(file_name_and_path)
    '''
    
    files = [...]
    
    iolite=r'C:\Program Files (x86)\iolite-software\iolite4\iolite4.exe'
    env = {
        'PATH': 'C:\\Program Files (x86)\\iolite-software\\iolite4\\',
        'PYTHONPATH': 'C:\\Program Files (x86)\\iolite-software\\iolite4\\python38.zip',
        'SYSTEMROOT': 'C:\\Windows'
    }
    
    for file in files:
        script_for_file = script.replace('$file', file)
        print(subprocess.run([iolite, '-p', script_for_file], env=env, capture_output=True))

    I've used something like this in the past and it should get the job done.

    All the best,

    • Joe