2

I wrote a python script to synchronize two folders given as input. I use it to synchronize folders between my phone and a laptop, but, thanks to buggy os.path.abspath, it works correctly only when I give absolute pathnames of the folders to it.

My question is: will the mount point of my phone be same every time I plug it in? If so, I could store its path as a shell variable. If not, can you suggest a way I could avoid typing/copy-pasting a long pathname every time I use this script?

1

Your phone is probably being automatically mounted via udisks, which prefers to use the same path each time. Of course, a udisks upgrade may change the path (and has in the past). So too might changing the label on the filesystem, etc.

You can find the mount point, however, by asking the udisks service over the dbus (you could also use this to mount and unmount the phone as needed). There are Python libraries to help; some quick searching found: http://lazka.github.io/pgi-docs/index.html#UDisks-2.0 https://github.com/umago/python-udisks and a few more.

If your phone isn't being handled by udisks, likely whatever is handling it also has an API, which you can probably use from Python.

  • My phone uses mtp to connect. But mtp-tools is telling me that my phone model isn't supported. Anyways, it would be enough if something can find out the mount point of my phone and store it somewhere when I plug it in. Btw I noticed today the mount point is not same everytime. – saga Sep 1 '16 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.