Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
logging.basicConfig(
format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING)
callback_obj = gp.check_result(gp.use_python_logging())
camera = gp.check_result(gp.gp_camera_new())
gp.check_result(gp.gp_camera_init(camera))
print('Getting list of files')
files = list_files(camera)
if not files:
print('No files found')
return 1
path = files[0]
print('Copying %s to memory in 100 kilobyte chunks' % path)
folder, name = os.path.split(path)
file_info = gp.check_result(gp.gp_camera_file_get_info(
camera, folder, name))
data = bytearray(file_info.file.size)
view = memoryview(data)
chunk_size = 100 * 1024
offset = 0
while offset < len(data):
bytes_read = gp.check_result(gp.gp_camera_file_read(
camera, folder, name, gp.GP_FILE_TYPE_NORMAL,
offset, view[offset:offset + chunk_size]))
offset += bytes_read
print(bytes_read)
print(' '.join(map(str, data[0:10])))
image = Image.open(io.BytesIO(data))
image.show()
gp.check_result(gp.gp_camera_exit(camera))
return 0
def get_camera_file_info(camera, path):
folder, name = os.path.split(path)
return gp.check_result(
gp.gp_camera_file_get_info(camera, folder, name))
def get_camera_file_info(camera, path):
""" Returns the details of the specific image passed in """
folder, name = os.path.split(path)
return gp.check_result(
gp.gp_camera_file_get_info(camera, folder, name))
def get_camera_file_info(camera, path):
""" Returns the details of the specific image passed in """
folder, name = os.path.split(path)
return gp.check_result(
gp.gp_camera_file_get_info(camera, folder, name))