Skip to content

Create file from string #1

@robertbilling

Description

@robertbilling

I'm trying to write files containing a UUID to memory cards inside cameras and phones so that I can identify a card that has been seen before when a device is plugged in.

This works:

`#!/usr/bin/python3

#Tag, untag and retag memory cards

import os
import sys
import gphoto2 as gp
from ctypes import *

def main():
cam = gp . Camera ()
cam . init ()
val, tfile = gp . gp_file_open ( "orig.uui" )
p = cam . folder_put_file ( "/store_00010001/DCIM", "elephant.uui",
gp . GP_FILE_TYPE_NORMAL, tfile)
main()

`
It copies a UUID from a text file created by uuidgen to the card in the camera.

However I have completely failed to write a UUID from a Python text string without going via a disk file. I have tried creating a file and using set_data_and_size() but have not found any combination of parameters that will work.

Is there somewhere an example program for set_data_and_size() ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions