whitebox-tools icon indicating copy to clipboard operation
whitebox-tools copied to clipboard

python implementation changes the current working directory

Open cefect opened this issue 8 months ago • 3 comments

calling something like the below seems to change the working directory. This seems like a bad idea (especially without warning the user) as writes to relative file paths don't land as expected. I for one lost some time trying to figure out where my files were going.

pre_working_dir =  os.getcwd()
if not wbt.cost_distance(wse_fp,cost_fp, 
                         os.path.join(out_dir, f'01_outAccum.tif'),
                         backlink_fp) == 0:
    raise IOError('cost_distance')

assert pre_working_dir==os.getcwd(), 'directory changed unexpectedly'

cefect avatar Jun 01 '24 12:06 cefect