I am working with gphoto2, most commands are working, but I don't know how to use the output from command-line for next operations.
For example:
I want to get list of photos in camera
command = ["sudo","gphoto2","--get-all-files","--skip-existing"]
call(command)
Result:
There is no file in folder '/'.
There is no file in folder '/store_00010001'.
There is no file in folder '/store_00010001/DCIM'.
There are 6 files in folder '/store_00010001/DCIM/100EOS5D'.
#1 OM6_0018.JPG rd 12335 KB image/jpeg
#2 OM6_0019.JPG rd 12686 KB image/jpeg
#3 OM6_0020.JPG rd 12500 KB image/jpeg
#4 OM6_0021.JPG rd 12438 KB image/jpeg
#5 OM6_0022.JPG rd 12668 KB image/jpeg
#6 OM6_0023.JPG rd 12760 KB image/jpeg
What I aim to get output in JSON or Python array:
['OM6_0018.JPG', 'OM6_0019.JPG', 'OM6_0020.JPG', ...]
Any suggestion is appreciated.
So, I have no idea how gphoto works, but I am going to take a wild guess that instead of doing a subprocess call, you should instead just do this:
See here for full example: https://github.com/jim-easterbrook/python-gphoto2/blob/master/examples/list-files.py