Quantcast
Channel: Adobe Community : Popular Discussions - Lightroom SDK
Viewing all 53524 articles
Browse latest View live

Anybody have some unicode string handling code I could use?

$
0
0

Text handling plugins are not working for some users, since Lua and Lr are not on the same page char-representation-wise.

 

For example, if you enter

 

À

 

in Lightroom, it's getting interpreted as

 

À

 

in Lua.

 

in non-plugin environment, one could just use slnunicode, however in plugin one needs pure lua solution.

 

Anybody?

 

ref: http://lua-users.org/wiki/LuaUnicode

 

R


i'd like to poll a website regularly. what's a good way?

$
0
0

I tried using Rob Cole's example in Cooksmarks to send data to lightroom://[plugin_id] but it just never worked for me. so now i'd just like to do some regular polling of a website from within a plugin. what might be a good way to do that?  i tried running an asynchronous task calling a function with a sleep in it that kept hitting a site every second, but i got yelled at by the Lightroom Lua interpreter about trying to sleep while not in a task (i thought i was in a task, but that's a separate issue).

Problem with startAsyncTask to fill value into popup_menu items

$
0
0

Hi everybody,

 

I encountered a problem to fill the popup_menu items with a startAsyncTask function.

 

This is my function:

 

function getLabelColor(propertyTable)          local catalog = LrApplication:activeCatalog()          local labelColor = catalog:getLabelMapToColorName()          propertyTable.label_red = getKeyForValue(labelColor, "red") -- getKeyForValue return the key for the value          propertyTable.label_green = getKeyForValue(labelColor, "green")          propertyTable.label_yellow = getKeyForValue(labelColor, "yellow")          propertyTable.label_blue = getKeyForValue(labelColor, "blue")          propertyTable.label_purple = getKeyForValue(labelColor, "purple")
end

 

I run the async task on sectionsForTopOfDialog:

 

function exportServiceProvider.sectionsForTopOfDialog(f, propertyTable)          LrTasks.startAsyncTask(function ()                    getLabelColor(propertyTable)          end)          return MLDialogs.settings(f, propertyTable)

end

 

On my MLDialogs.settings function I've this:

 

f:popup_menu {     title = LOC "$$$/ML/ExportManager/ASLabel=Color label for Dual ISO file :",     items = {           { title = "", value = "" },           { title = propertyTable.label_red, value = "red" }             { title = propertyTable.label_yellow, value = "yellow" },          { title = propertyTable.label_green, value = "green" },          { title = propertyTable.label_blue, value = "blue" },          { title = propertyTable.label_purple, value = "purple" },     },     value = bind "label",     size = 'small'
},

 

When I run the plugin, it display the value from the color label, but if I change the values for the color, when I run the plugin, the display values is the old (but on the log I've the new, so the title isn't refreshed).

 

I found that the async function return value after sectionsForTopOfDialog is displayed.

I try to change title = propertyTable.label_red to title = bind 'label_red' but I've an error:

 

Invalid parameter not satisfying: aString != nil

 

you can found the source here https://bitbucket.org/kichetof/lr_cr2hdr/src

 

I hope you can help me!

Cheers

Tof

Develop setting "orientation"?

$
0
0

I've noticed that photo:getDevelopSettings() returns a setting "orientation", which takes on the values "AB" and "BC" (perhaps others?).  When you create a preset through the UI, this setting is copied into the preset if you select the categories Graduated Filters or Radial Filters.


Anyone know what the setting does?  I've tried changing its value when creating and applying a plugin preset but haven't noticed any difference in the photo.

Plugin to close lightroom and open another program.

$
0
0

I am looking over the SDK and forums but cannot find anything....

 

I am looking for a way to have a plugin close lightroom and open another program. Any ideas? Does the SDK provide a command to close lightroom and I am overlooking it.

 

The best idea I can come up with is having the plugin communicate with the external app and having that app close lightroom via OS commands. My concern with this approach is I will either have to kill the processes which Lightroom might not like or send keyboard commands to lightroom which always seems like trouble.

 

Thanks!

Working with LRSocket, receiving

$
0
0

I'm trying to set up a communication between Lightroom and another process using LRSocket. I've worked out an LrSocket.bind with mode = "send" and that's all working fine but I cannot for the life of me get a receive working. Here's my Lua code:

 

 

Connection = {

}

function Connection.Listen( self, context )

 

        local running = true

 

        self.Listener = LrSocket.bind {

 

       functionContext = context,

            port = 4242,

            plugin = _PLUGIN,

            mode = "receive",

 

            onConnected = function( socket, port )

                 Debug.logn( "Listener connected on port " .. port )

            end,

 

            onMessage = function( socket, message )

                 Debug.logn( "Listener Got: " .. message );

            end,

 

            onClosed = function( socket )

                 Debug.logn( "Listener Closed on Port: " .. myPort )

                 running = false

            end,

 

            onError = function( socket, err )

                 if err == "timeout" then

                 end

            end,

 

  } -- bind

 

  while running do

  LrTasks.sleep( 1/2 ) -- seconds

  end

 

  self.Listener:close()

 

 

end

 

I've been testing with both telnet and a short python snippet shown below. Telnet fails to connect at all, the Python code connects and the onConnected callback is called but, although text is being sent, the onMessage callback doesn't get called. I wondered if anyone had managed to make this work at all or if anyone has any pointers on what might be going wrong.

 

import socket, select, sys, time

 

def Send( msg ):

 

    TCP_IP = 'localhost'

    TCP_PORT = 4242

    BUFFER_SIZE = 1024

    MESSAGE = "Hello, World!"

 

    print "Sending on port ",  TCP_PORT

 

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    s.settimeout(2)

    s.connect((TCP_IP, TCP_PORT))

    s.send(MESSAGE)

    print "Sent"

    s.close()

 

    time.sleep( 5 )

    print "Closed"

 

Send( "Test")

 

Many thanks.

Set system path on Mac?

$
0
0

I'm helping with a plugin that uses some open source command line tools. The plugin ships with all the dependencies bundled into a "bin" directory which works fine in Windows but the Mac searches the system path when these programs are called. Mac users were told to install the files in /usr/bin but now with "El Capitan" that isn't possible. It also seems that the plugin cannot access anything installed in /usr/local/bin even though it is in the system path.

 

Even before "El Capitan" we were discussing ways for the Mac version to behave like the Windows version and use the files installed in the plugin's "bin" directory.

 

 

    if MAC_ENV then        local exportPath = 'export PATH="'        local toolsPath = LrPathUtils.child(_PLUGIN.path, 'bin"')        local systemPath = ':$PATH'        local searchPath = exportPath..toolsPath..systemPath
--        LrTasks.execute(searchPath) -- this doesn’t work

 

The script calls this dependency check:

 

-- Check for Mac dependencies
function MLProcess.checkDependencies()    return "exec which dcraw exiftool"
end

 

The only way it will work on "El Capitan" is if dcraw and exiftool are installed in /usr/bin. Some users are skilled enough to turn off System Integrity Protection to install the tools but that shouldn't be necessary. Another workaround is to start Lightroom from a shell script that sets the path for that session before launching LR. Here's an example:

 

LR.command

export PATH="/Library/Application Support/Adobe/Lightroom/Modules/cr2hdr.lrplugin/bin":$PATH
/Applications/Adobe\ Lightroom/Adobe\ Lightroom.app/Contents/MacOS/Adobe\ Lightroom

 

Of course these are just workarounds--how can the system path be set? Is it even possible?

Copy develop settings from one photo to another: having problems! photo:getDevelopSettings LrDevelopController.setValue

$
0
0

I've also attached the full code at the bottom of this message in case that helps, but, to summarize,

 

I have a lua plugin (MIDI2LR by rsjaffe) that receives MIDI messages from an application through a LrSocket. Everything has been working, but I've tried to add copy/paste develop settings without success.

 

In the following code, the copy settings is:

function copySettings()

    local photo = LrApplication.activeCatalog():getTargetPhoto()

    settings = photo:getDevelopSettings()

end

and the paste settings is:

function pasteSettings()

    applySettings(settings) 

end


function applySettings(set) --still experimental

    if LrApplicationView.getCurrentModuleName() ~= 'develop' then

            LrApplicationView.switchToModule('develop')

    end

    for x,v in pairs(set) do

--      SERVER:send(string.format('%s %d\n', x, develop_lerp_to_midi(v)))

--      PARAM_OBSERVER[x] = v

      LrDevelopController.setValue(x,v)

    end

end


The functions do get called, but nothing happens to the target photo. I've also been unable to attach a debugger (tried ZeroBrane studio as described in Debugging Adobe Lightroom plugins with ZeroBrane Studio - ZeroBranebut can't get Lightroom to load mobdebug.lrmodule.


Can someone point out where I'm going wrong?

Thanks.


 

 

 

 

require 'strict.lua' -- catch some incorrect variable names

require 'Develop_Params.lua' -- global table of develop params we need to observe

local LrApplication      = import 'LrApplication'

local LrApplicationView  = import 'LrApplicationView'

local LrDevelopController = import 'LrDevelopController'

local LrFunctionContext  = import 'LrFunctionContext'

local LrSelection        = import 'LrSelection'

local LrShell            = import 'LrShell'

local LrSocket            = import 'LrSocket'

local LrTasks            = import 'LrTasks'

local LrUndo              = import 'LrUndo'

 

 

-- File-local consts

local RECEIVE_PORT = 58763

local SEND_PORT    = 58764

local PICKUP_THRESHOLD = 4

 

 

-- File-local vars

local CopyUUID

local settings

local LAST_PARAM = ''

local PARAM_OBSERVER = {}

local PICKUP_ENABLED = true

local SERVER = {}

 

 

--File-local function declarations, advance declared to allow it to be in scope for all calls.

--When defining pre-declared function, DO NOT USE local KEYWORD again, as it will define yet another local function.

--These declaration are intended to get around some Lua gotcha's.

local applySettings

local copySettings

local develop_lerp_to_midi

local midi_lerp_to_develop

local pasteSettings

local processMessage

local sendChangedParams

local startServer

local updateParam

 

 

local ACTIONS = {

 

 

    ['DecrementLastDevelopParameter'] = function () LrDevelopController.decrement(LAST_PARAM) end,

    ['VirtualCopy']      = function () LrApplication.activeCatalog():createVirtualCopies() end,

    ['ToggleScreenTwo']  = LrApplicationView.toggleSecondaryDisplay,

    ['CopySettings']    = copySettings,

    ['PasteSettings']    = pasteSettings,

}

 

 

local TOOL_ALIASES = {

    ['Loupe']          = 'loupe',

    ['CropOverlay']    = 'crop',

    ['SpotRemoval']    = 'dust',

    ['RedEye']          = 'redeye',

    ['GraduatedFilter'] = 'gradient',

    ['RadialFilter']    = 'circularGradient',

    ['AdjustmentBrush'] = 'localized',

}

 

 

local SETTINGS = {

    ['Pickup'] = function(enabled) PICKUP_ENABLED = (enabled == 1) end,

}

 

 

function copySettings()

    local photo = LrApplication.activeCatalog():getTargetPhoto()

    settings = photo:getDevelopSettings()

end

 

 

function pasteSettings()

    applySettings(settings) 

end

 

 

function midi_lerp_to_develop(param, midi_value)

    -- map midi range to develop parameter range

    local min,max = LrDevelopController.getRange(param)

--    if(param == 'Temperature') then

--        min = 3000

--        max = 9000

--    end

   

    local result = midi_value/127 * (max-min) + min

    return result

end

 

 

function develop_lerp_to_midi(param)

    -- map develop parameter range to midi range

    local min, max = LrDevelopController.getRange(param)

--    if(param == 'Temperature') then

--        min = 3000

--        max = 9000

--    end

   

    local result = (LrDevelopController.getValue(param)-min)/(max-min) * 127

    return result

end

 

 

function updateParam(param, midi_value)

    -- this function does a 'pickup' type of check

    -- that is, it will ensure the develop parameter is close

    -- to what the inputted command value is before updating it

    if LrApplicationView.getCurrentModuleName() ~= 'develop' then

            LrApplicationView.switchToModule('develop')

    end

   

    if((not PICKUP_ENABLED) or (math.abs(midi_value - develop_lerp_to_midi(param)) <= PICKUP_THRESHOLD)) then

        PARAM_OBSERVER[param] = midi_lerp_to_develop(param, midi_value)

        LrDevelopController.setValue(param, midi_lerp_to_develop(param, midi_value))

        LAST_PARAM = param

    end

end

 

 

function applySettings(set) --still experimental

    if LrApplicationView.getCurrentModuleName() ~= 'develop' then

            LrApplicationView.switchToModule('develop')

    end

    for x,v in pairs(set) do

--      SERVER:send(string.format('%s %d\n', x, develop_lerp_to_midi(v)))

--      PARAM_OBSERVER[x] = v

      LrDevelopController.setValue(x,v)

    end

end

 

 

-- message processor

function processMessage(message)

    if type(message) == 'string' then

        -- messages are in the format 'param value'

        local _, _, param, value = string.find( message, '(%S+)%s(%d+)' )

     

        if(ACTIONS[param] ~= nil) then -- perform a one time action

            if(tonumber(value) == 127) then ACTIONS[param]() end

        elseif(param:find('Reset') == 1) then -- perform a reset other than those explicitly coded in ACTIONS array

          if(tonumber(value) == 127) then LrDevelopController.resetToDefault(param:sub(6)) end

        elseif(param:find('SwToM') == 1) then -- perform a switch to module

            if(tonumber(value) == 127) then LrApplicationView.switchToModule(param:sub(6)) end

        elseif(param:find('ShoVw') == 1) then -- change application's view mode

            if(tonumber(value) == 127) then LrApplicationView.showView(param:sub(6)) end

        elseif(param:find('ShoScndVw') == 1) then -- change application's view mode

            if(tonumber(value) == 127) then LrApplicationView.showSecondaryView(param:sub(10)) end

        elseif(TOOL_ALIASES[param] ~= nil) then -- switch to desired tool

            if(tonumber(value) == 127) then

                if(LrDevelopController.getSelectedTool() == TOOL_ALIASES[param]) then -- toggle between the tool/loupe

                    LrDevelopController.selectTool('loupe')

                else

                    LrDevelopController.selectTool(TOOL_ALIASES[param])

                end

            end

        elseif(SETTINGS[param] ~= nil) then

            SETTINGS[param](tonumber(value))

        else -- otherwise update a develop parameter

            updateParam(param, tonumber(value))

        end

    end

end

 

 

-- send changed parameters to MIDI2LR

function sendChangedParams( observer )

    for _, param in ipairs(DEVELOP_PARAMS) do

        if(observer[param] ~= LrDevelopController.getValue(param)) then

            SERVER:send(string.format('%s %d\n', param, develop_lerp_to_midi(param)))

            observer[param] = LrDevelopController.getValue(param)

            LAST_PARAM = param

        end

    end

end

 

 

function startServer(context)

    SERVER = LrSocket.bind {

          functionContext = context,

          plugin = _PLUGIN,

          port = SEND_PORT,

          mode = 'send',

          onClosed = function( socket ) -- this callback never seems to get called...

            -- MIDI2LR closed connection, allow for reconnection

            -- socket:reconnect()

          end,

          onError = function( socket, err )

            socket:reconnect()

          end,

        }

end

 

 

-- Main task

LrTasks.startAsyncTask( function()

    LrFunctionContext.callWithContext( 'socket_remote', function( context )

        LrDevelopController.revealAdjustedControls( true ) -- reveal affected parameter in panel track

       

        -- add an observer for develop param changes

        LrDevelopController.addAdjustmentChangeObserver( context, PARAM_OBSERVER, sendChangedParams )

       

        local client = LrSocket.bind {

            functionContext = context,

            plugin = _PLUGIN,

            port = RECEIVE_PORT,

            mode = 'receive',

            onMessage = function(socket, message)

                processMessage(message)

            end,

            onClosed = function( socket )

                -- MIDI2LR closed connection, allow for reconnection

                socket:reconnect()

               

                -- calling SERVER:reconnect causes LR to hang for some reason...

                SERVER:close()

                startServer(context)

            end,

            onError = function(socket, err)

                if err == 'timeout' then -- reconnect if timed out

                    socket:reconnect()

                end

            end

        }

       

        startServer(context)

       

        while true do

            LrTasks.sleep( 1/2 )

        end

       

        client:close()

        SERVER:close()

    end )

end )

 

LrTasks.startAsyncTask( function()

    if(WIN_ENV) then

        LrShell.openFilesInApp({_PLUGIN.path..'/Info.lua'}, _PLUGIN.path..'/MIDI2LR.exe')

    else

        LrShell.openFilesInApp({_PLUGIN.path..'/Info.lua'}, _PLUGIN.path..'/MIDI2LR.app') -- On Mac it seems like the files argument has to include an existing file

    end

end)


Check if external progam is installed - LrTasks.startAsyncTask wait for answer

$
0
0

In one of my plug-ins I need to check whether an external tool is installed.

For this I added in the Plug-in manager a section called "Configuration" with a button.
However I don't want to bother my clients with searching for the executable on the file system.

 

So I want to execute with a command to check whether it is installed.

LrTasks.execute( command )

Since the code is added to PluginInfoProvider I can't use LrTasks.execute directly, because then I get the error:

We can only wait from within a task.

 

So I embedded it within a LrTasks.startAsyncTask ( function()

...

end)

How can I wait for the async task to finish and get the results?

Top of dialog section in Plugin Manager not displaying

$
0
0

Hi All, long time reader first time poster.

 

Basically I'm very new to LUA and Lr SDK so please be gentle.

 

I'm writing a simple toolbar that automates a lot of tasks I do in Lightroom for tethering various cameras in various naming formats.

 

I cannot seem to get the sectionsForTopOfDialog to do anything. I know I'm missing something simple like a function call to get it to run but there is nothing I can see in the docs or manual to help.

 

Any assistance would be greatly appreciated.

 

Here is my info.lua:

return {        LrSdkVersion = 3.0,    LrSdkMinimumVersion = 2.2, -- minimum SDK version required by this plug-in    LrToolkitIdentifier = 'com.adobe.lightroom.sdk.lrtoolbar',    LrPluginName = LOC "$$$/LRToolbar/PluginName=LR Toolbar",  LrInitPlugin = "LRToolbar.lua",  LrForceInitPlugin = true,  LrPluginInfoUrl = "http://www.clinicalimaging.com.au",  LrEnablePlugin = "LRToolbar.lua",  LrPluginInfoProvider = "LRToolbarInfo.lua",      -- Add the menu item to the File menu.        LrExportMenuItems = {        title = "LR Toolbar",        file = "LRToolbar.lua",    },    -- Add the menu item to the Library menu.        LrLibraryMenuItems = {        {            title = LOC "$$$/LRToolbar/CustomDialog=LR Toolbar",            file = "LRToolbar.lua",        },    },    VERSION = { major=0, minor=1, revision=1, build=100, },

}

 

For some reason the forums insist on wrapping anything else I paste in a table so I will paste my LrPluginInfoProvider file in the next post.

Plugin: external control of Lightroom (OS X)

$
0
0

So A while back I started a little project that would allow me to send commands to Lightroom, execute lua code & return stuff back. Basically a Lightroom plugin and a lightweight server that talk to each other, the server sending the plugin Lua code to execute when triggered to do so by shortcut keys. Since then it's grown a bit. I can:

 

  • Use shortcut keys to trigger execution of Lua code in Lightroom
  • Build HTML pages with sliders & buttons that send Lua code to Lightroom for execution and receive information back.
  • Have Lightroom send events on active source, active photo & module changes to HTML pages, keeping them up to date on user selections
  • Use Alfred, the Spotlight replacement (see here), send Lua code to Lightroom for execution and receive return data

 

It's become an integral part of my workflow. I have shortcut key driven dev param editing, dev param editing from an HTML page, shortcut driven jumping between sources and active source history stacks that I can jump around in using shortcut keys.

 

It's extremely powerful this idea of having Lightroom execute code sent from a remote source like this - although not necessarily very friendly if you don't code, which I'm thinking on - and now I'm wondering whether to take it further.

 

So do people think this is worth pursuing? If so I'll work on release notes and some demo screencasts, maybe think about some kind of test programme.

 

Thoughts appreciated.

Lightroom API IOS to load showroom

$
0
0

Hi,

 

I'd like to build an IOS app to show an LR sync album.

 

I followed the workflow to get an API Key How to complete the Production Client ID Request – Adobe Creative SDK. but when I select Lightroom, there is the message "Many services are only available through paid license or subscription. If you believe you should have access to a disabled service please contact your Adobe sales representative."

 

I have to pay to get an API Key ? Same service for Vimeo for example is included in the licence...

 

Thx.

LrTasks.execute return code 65280?

$
0
0

Hi,

 

I have an issue with a Lightroom plugin that uses a command line tool to communicate with another application, on MacOS. The Lua code in the plugin calls on to the command line tool with a call to LrTasks.execute. This works perfectly fine with all tests, and has been working nicely for quite some time now, with various users not reporting any issues. Except for one user now, where the command line can't be launched.

 

If I launch the command line tool manually, everything works nicely. But when launched from the plugin, after enabling some logging in the plugin, I can see that I get a return code of '65280', and not much more. The system console log doesn't say much either, and nothing notable was appearing during the tests with this user.

This user is on MacOS 10.13.6, and has another computer where everything works fine. We tried disabling his antivirus, just in case, but that didn't do much. Apart from that, I couldn't see what would explain the difference between his two computers.

 

Are there any Lightroom logs somewhere that would give more info on what's happening behind the scenes?

Or would anyone know a bit more about what is causing this return code?

Change metadataFieldsForPhotos values programmatically

$
0
0

Hello,

 

I want to change my Custom Metadata fields while plugin works but, as far as I know,  we need to define metadataFieldsForPhotos in a lua file and then call this in Info.lua. I want to fetch data with LrHttp.get method but this method works in LrTask and I don't have a chance because I need to call it from Info.Lua.

 

I believe that it should be a way to change custom metadata fields but I didn't find it.

 

Any suggestions will be greatly appreciated.

 

Thanks in advance

Lightroom API reference for metadata read/write - specifically facial data

$
0
0

I'm looking for documentation for Lightroom classic related to reading and writing metadata for the catalog (file metadata and data stored in the catalog).  I'm specifically interested in the data related to facial data (regions defined for face in an image, name associated with region, etc).  I've been hunting and playing with the SDKs for a couple days and I can't find what I'm looking for (beyond basic IPTC/EXIF metadata).


Installing Lightroom and Visual C++

$
0
0

Hi,

 

I am just discovering Lightroom CC through videos tutorial and I have just recently decided to try it by myself as it seems very powerfull.

 

Unfortunately, when I try to install it I have got the famous error message :

 

"The application has failed to start because the side by side configuration is incorrect please see the application event log or use the command line sxstrace.exe tool for more detail"

 

It seems that this message has something to do with Visual C++ package installed on my Windows 10 PC Desktop but I don't know exactely what to do.

 

Many thanks for your help,

 

Patgom145

User Scripting (not plugins) in Lightroom?

$
0
0
Hi,

I don't know if any of you have been following the Export Keywords problem, but a KB article including a fix has been published about it. http://kb.adobe.com/selfservice/viewContent.do?externalId=kb405074&sliceId=2

This wouldn't normally be a subject for this forum, but the fix (an SQL update) is delivered via a .lua file that is:
* installed into a Scripts directory in the Lightroom presets directory (it wasn't present on my system prior to this)
* Enables a Scripts menu (to the right of the Window menu) and the first item is "Open User Scripts Folder"
* presents a dialog box (with a few options) that runs the SQL then restarts the product

Why I'm interested is it appears the Lightroom team has already baked a User Scripting mechanism into the product, beyond the plugin SDKs that have officially been announced. This hints at wider capability for us to extend the product - that certainly grabs my attention.

This is the first time I've seen any form of scripting (beyond that included in the Plugin SDK) publicly acknowledged albiet indirectly. Does anyone know where to find documentation about User Scripting capabilities/SDK/etc? Can anyone glean additional information from the fix that was published? I'm hoping one of you more experienced development types may be able to shed more light on this.

Thanks,
Matt

Using startAsyncTask and getting a return value

$
0
0

Hello,

 

I'm just starting to try and learn LUA and the whole Lightroom SDK.  Here is a sample of my code:

 

local lrApplication = import 'LrApplication'

local LrTasks = import 'LrTasks'

 

local activeCatalog = lrApplication.activeCatalog()

local currentPhotos = activeCatalog:getMultipleSelectedOrAllPhotos()

local y = LrTasks.startAsyncTask(function() return currentPhotos[1]:getFormattedMetadata('fileName') end)

 

wheneven I check or try to use y it is nil.

 

Please someone tell me the stupid thing I'm doing wrong so I don't lose any more of my dwindling hair. 

 

I know that currentPhotos has 5 photos in it's collections because later on I do this:

     for i, onePhoto in ipairs(currentPhotos) do

and it loops through 5 times, which matches up to the number of photos in the folder I have selected in Lightroom.

 

 

Thanks.

Lr5.2 - anybody having problems with external apps hanging.

$
0
0

@Lr5, I've been having trouble with commands like sqlite3 & image-magick/convert-or-mogrify & exiftool returning control to plugin. Most of the time it works, but sometimes they just hang. Only way to get past such problem when it occurs is reloading the plugin. Anybody else?

 

To be clear, problem is: sometimes LrTasks.execute never returns.

 

I never had this problem before Lr5, but haven't had user complaints yet, so dunno if problem is my machine, or Lr, or...

 

Any input or ideas appreciated - thanks in advance..

 

R

improving the reliability of external command calls

$
0
0

This is probably a Rob Cole question since I'm doing things under the Elare Framework, but it might apply more generally.  I'm

using a service call that looks something like

app:call( Service:new{ name=serviceName, async=true,   main=function( call )                     local catPath =  LrPathUtils.child( _PLUGIN.path, "appDb.sqlite")               if not str:is( catPath ) then                    --app:show{ warning="Catalog path can not be blank." }                    --myLogger:trace("one")                    call:cancel()                    return               end               if catPath == catalog:getPath() then                    call:cancel()                    return               end                         local LrLogger = import 'LrLogger'               local expResp = app:getPref( 'expectResponse' )               local outHdl               if expResp then                    outHdl = 'del'               else                    outHdl = nil               end                          if _win_env() then                    sqlite = LrPathUtils.child( _PLUGIN.path, 'sqlite3.exe' )               else                    sqlite = LrPathUtils.child( _PLUGIN.path, 'sqlite3' )               end               if string.sub(strSQL, string.len(strSQL), string.len(strSQL))~=";" then                    strSQL=strSQL ..";"               end                          local s, m = fso:writeFile( scriptPath, strSQL )               local param = str:fmt( '"^1" ".read "^2""', catPath:gsub( "\\", "\\\\" ), scriptPath:gsub( "\\", "\\\\" ) )                local s, m, c = app:executeCommand( sqlite, param, nil, tempFileName, nil ) -- nil => no specific targets, nil => temp-file for capturing output is fine, 'del' => get output, then delete output file.               local out=fso:readFile(tempFileName )                     if not bwlCachedQuery then                    fso:deleteFile(scriptPath)                    fso:deleteFile(tempFileName)               end               updateDialog(out, typeIn, catId, generatorId, generator, imageId, strSQL, timeThrough)          end } )

It basically writes some SQL into a temp file, calls executeCommand to run sqlite3.exe or the Mac equivalent, reads the result file, getting pipe-delimited data, and then it deletes the temp files. (This is an oversimplification because sometimes it actually caches the result files and uses them later without having to do the Sqlite query.)   I've noticed, though, that some fraction of the time, a good query that should result in valid data produces an empty file.  I have no idea why, but it's a source of some vexing unreliability.  I've actually put in some code to re-run the query when this happens (all my Updates and Inserts have a small select query on the end so they always produce some data).  I was wondering why this might be happening? I should mention that the names of my temp files include long random numbers, so it's not a problem of one file overwriting another.

Viewing all 53524 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>