I am playing around with gphoto2 and I found that camera
object has a public function file_get_info()
. I would like to know:
But so far I have failed to find any information about it.
This is what I do:
import gphoto2 as gp
portInfoList = gp.PortInfoList()
portInfoList.load()
abilitiesList = gp.CameraAbilitiesList()
abilitiesList.load()
cams = abilitiesList.detect(portInfoList)
for name, addr in cams:
print("%s at port %s"%(name, addr))
idx = portInfoList.lookup_path(addr)
camera = gp.Camera()
camera.set_port_info(portInfoList[idx])
camera.init()
camera.file_get_info()
This is what I get:
TypeError: Camera_file_get_info expected at least 2 arguments, got 0
What is even more frustrating is that no matter how hard I google I cannot find anything about the Camera_file_get_info
function.
Am I approaching this wrong?
The file_get_info
method on a Camera
object is a more Pythonic version of the libgphoto2 function gp_camera_file_get_info
. This would be a better term for web searching.
There are several ways to get the information you're looking for. Like other Python modules you can use pydoc:
pydoc3 gphoto2.Camera.file_get_info
Help on method_descriptor in gphoto2.Camera:
gphoto2.Camera.file_get_info = file_get_info(...)
file_get_info(char const * folder, char const * file, Context context)
Retrieves information about a file.
Parameters
----------
* `camera` :
a Camera
* `folder` :
a folder
* `file` :
the name of the file
* `info` :
* `context` :
a GPContext
Returns
-------
a gphoto2 error code
See also gphoto2.gp_camera_file_get_info
This is taken from the "C" documentation, so the parameter list is a bit confusing - info
is a parameter in the C version but not in Python. The two parameters you need are folder
and file
- these tell the function which file you want information about.
You might prefer to use the C documentation directly: http://www.gphoto.org/doc/api/gphoto2-camera_8h.html#adda54321b1947b711d345936041f80c7 This includes a link to the info
structure.
Finally, the list-files.py
example program included in python-gphoto2
shows a use of file_get_info
.