How to use the gphoto2.gp_camera_exit function in gphoto2

To help you get started, we’ve selected a few gphoto2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
if (request.form.get('aperture') != 'implicit auto'):
                node = config.get_child_by_name('aperture')
                node.set_value(str(request.form.get('aperture')))
            if (request.form.get('shutter') != "auto"):
                node = config.get_child_by_name('shutterspeed')
                node.set_value(str(request.form.get('shutter')))
            if (request.form.get('exp') != None):
                node = config.get_child_by_name('exposurecompensation')
                node.set_value(str(request.form.get('exp')))
            camera.set_config(config, context)
            gp.check_result(gp.gp_camera_exit(camera))

        if request.form['CamSubmit'] == 'preview':
            app.logger.debug('-- Camera Preview selected')
            getPreviewImage(camera, context, config)
            gp.check_result(gp.gp_camera_exit(camera))
            return redirect(url_for('camera', preview=1))

    except gp.GPhoto2Error as e:
        app.logger.debug('Camera POST error: ' + e.string)
        flash(e.string)
    except Exception as e:
        app.logger.debug('Unknown camera POST error: ' + str(e))

    return redirect(url_for('camera'))
github jim-easterbrook / python-gphoto2 / examples / copy-data.py View on Github external
##        gp.gp_camera_file_get_info(camera, folder, name))
##    file_data = bytearray(info.file.size)
##    count = gp.check_result(gp.gp_file_slurp(camera_file, file_data))
##    print(count, 'bytes read')
    # or read data using 'get_data_and_size' which allocates its own buffer
    file_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))
    data = memoryview(file_data)
    print(type(data), len(data))
    print(data[:10].tolist())
    image = Image.open(io.BytesIO(file_data))
    image.show()
    print('After deleting camera_file and file_data')
    del camera_file, file_data
    print(type(data), len(data))
    print(data[:10].tolist())
    gp.check_result(gp.gp_camera_exit(camera))
    return 0
github jim-easterbrook / python-gphoto2 / examples / copy-chunks.py View on Github external
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
github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
'piDoW' : '',
        'piStartHour' : '',
        'piEndHour' : '',
        'piInterval' : '',
        'availableShots': 'Unknown'
    }
    app.logger.debug('This is a GET to Intervalometer')

    # Camera comms:
    try:
        camera = gp.Camera()
        context = gp.gp_context_new()
        camera.init(context)
        config = camera.get_config(context)
        templateData['availableShots'] = readValue (config, 'availableshots')
        gp.check_result(gp.gp_camera_exit(camera))
    except gp.GPhoto2Error as e:
        flash(e.string)
        app.logger.debug('GPhoto camera error in intervalometer: ' + str(e))
    except Exception as e:
        app.logger.debug('Unknown camera error in intervalometer: ' + str(e))

    ArdInterval = str(readString("3"))
    #Returns a string that's  (a byte to be treated as a bit array of days) followed by 2-digit strings of ,  & :
    app.logger.debug('Int query returned: ' + ArdInterval)
    if (ArdInterval != "Unknown") & (len(ArdInterval) == 7):
        for bit in range(1,8): # i.e. 1-7 inclusive
            if (ord(ArdInterval[0]) & (0b00000001<
github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
def copyNow():
    writeString("WC") # Sends the WAKE command to the Arduino (just in case)
    time.sleep(1);    # (Adds another second on top of the 0.5s baked into WriteString)
    try:
        camera = gp.Camera()
        context = gp.gp_context_new()
        camera.init(context)
        copy_files(camera)
        gp.check_result(gp.gp_camera_exit(camera))
    except gp.GPhoto2Error as e:
        flash(e.string)
        app.logger.debug("Transfer wasn't able to connect to the camera: " + e.string)
    except Exception as e:
        app.logger.debug('Unknown error in copyNow: ' + str(e))
    return
github jim-easterbrook / python-gphoto2 / examples / get-capture-target.py View on Github external
camera = gp.check_result(gp.gp_camera_new())
    gp.check_result(gp.gp_camera_init(camera))
    # get configuration tree
    config = gp.check_result(gp.gp_camera_get_config(camera))
    # find the capture target config item
    capture_target = gp.check_result(
        gp.gp_widget_get_child_by_name(config, 'capturetarget'))
    # print current setting
    value = gp.check_result(gp.gp_widget_get_value(capture_target))
    print('Current setting:', value)
    # print possible settings
    for n in range(gp.check_result(gp.gp_widget_count_choices(capture_target))):
        choice = gp.check_result(gp.gp_widget_get_choice(capture_target, n))
        print('Choice:', n, choice)
    # clean up
    gp.check_result(gp.gp_camera_exit(camera))
    return 0
github greiginsydney / Intervalometerator / Raspberry Pi / intvlm8r.py View on Github external
else:
                    raw_value = gp.check_result(
                        gp.gp_widget_get_value(datetime_config))
                    if fmt:
                        camera_time = datetime.strptime(raw_value, fmt)
                    else:
                        camera_time = datetime.utcfromtimestamp(float(raw_value))
                break
        imgfmtselected, imgfmtoptions   = readRange (camera, context, 'imgsettings', 'imageformat')
        wbselected, wboptions           = readRange (camera, context, 'imgsettings', 'whitebalance')
        isoselected, isooptions         = readRange (camera, context, 'imgsettings', 'iso')
        apselected, apoptions           = readRange (camera, context, 'capturesettings', 'aperture')
        shutselected, shutoptions       = readRange (camera, context, 'capturesettings', 'shutterspeed')
        expselected, expoptions         = readRange (camera, context, 'capturesettings', 'exposurecompensation')

        gp.check_result(gp.gp_camera_exit(camera))
        cameraData['cameraDate']    = camera_time.isoformat(' ')
        cameraData['focusmode']     = readValue (config, 'focusmode')
        cameraData['exposuremode']  = readValue (config, 'autoexposuremode')
        cameraData['autopoweroff']  = readValue (config, 'autopoweroff')
        cameraData['imgfmtselected']= imgfmtselected
        cameraData['imgfmtoptions'] = imgfmtoptions
        cameraData['wbselected']    = wbselected
        cameraData['wboptions']     = wboptions
        cameraData['isoselected']   = isoselected
        cameraData['isooptions']    = isooptions
        cameraData['apselected']    = apselected
        cameraData['apoptions']     = apoptions
        cameraData['shutselected']  = shutselected
        cameraData['shutoptions']   = shutoptions
        cameraData['expselected']   = expselected
        cameraData['expoptions']    = expoptions
github greiginsydney / Intervalometerator / Raspberry Pi / intvlm8r.py View on Github external
storage_info = gp.check_result(gp.gp_camera_get_storageinfo(camera))
        if len(storage_info) == 0:
            flash('No storage info available') # The memory card is missing or faulty
            
        abilities = gp.check_result(gp.gp_camera_get_abilities(camera))
        config = camera.get_config(context)
        files = list_camera_files(camera)
        if not files:
            fileCount = 0
            lastImage = ''
        else:
            fileCount = len(files)
            info = get_camera_file_info(camera, files[-1]) #Get the last file
            lastImage = datetime.utcfromtimestamp(info.file.mtime).isoformat(' ')
        gp.check_result(gp.gp_camera_exit(camera))
        templateData['cameraModel']              = abilities.model
        templateData['cameraLens'], discardMe    = readRange (camera, context, 'status', 'lensname')
        templateData['fileCount']                = fileCount
        templateData['lastImage']                = lastImage
        templateData['availableShots']           = readValue (config, 'availableshots')
        templateData['cameraBattery'], discardMe = readRange (camera, context, 'status', 'batterylevel')
    except gp.GPhoto2Error as e:
        flash(e.string)

    # Pi comms:
    piLastImage = ''
    piLastImageFile = ''
    try:
        FileList = list_Pi_Images(PI_PHOTO_DIR)
        PI_PHOTO_COUNT = len(FileList)
        if PI_PHOTO_COUNT >= 1: