I'm currently working on a embedded application on a raspberry pi 3 with Raspbian Jessie. The purpose of this applicatin is to write data in an excel on any usb key (which is always plug on the same port on the raspberry pi)
Current State Currently, the path where i want the data is directly written in my code
USBadress='/media/pi/DATA3'
Problem If the usb key is mounted elsewhere or if i'm using a different USB key my application doesn't work
What I tried
Modify the fstab to automaticlly mount /dev/sda1 on a specified folder (ex : media/pi/genericFolder but sometimes the usb key path is different (/dev/sdb1) and this solution only seems to work if you turn on your pi with your usb key already plug (which will be not be true everytime in my case)
I also tried with the UUID but this solution can't work cause my goal is to have a generic solution working with any usb key i plug in this specific usb port
I also saw some solutions with a rule specified on udev but I didn't understand very well...
Thank you in advance !!
Finally found a solution with the following line :
myPath=str(os.popen("mount | grep /media/pi").readlines())
MyPath=MyPath.split(" ")[2]