Lua compress script failing

Hello all,

I had a working automated compress and forward script working for about a year without error. In quest to become more fluent with Orthanc and to get more performance I spun up a couple test vms to compile Orthanc myself and to try out the docker versions. For the most part everything installed fine but my lua script keeps failing to compress the dicom files. I thought I might have compiled something wrong, so I did a fresh install of Debian Stretch and installed Orthanc 1.2 from synaptic. The script still fails and spits out errors, even though the same script has been working fine for a year. I have attached my error log while running Orthanc with the --verbose flag. Here is a link with the log as well. https://ghostbin.com/paste/rduu9

The logs are basically telling my that it cant find the file or directory that I have told the script to write to. It looks like it could be something extremely simple that I have left out or forgotten.

Here is the lua script in question

`

function OnStoredInstance(instanceId, tags, metadata, origin)

– Do not compress twice the same file
if origin[‘RequestOrigin’] ~= ‘Lua’ then
– Retrieve the incoming DICOM instance from Orthanc
local dicom = RestApiGet(‘/instances/’ … instanceId … ‘/file’)
– Write the DICOM content to some temporary file
local uncompressed = ‘/home/dicadmin/test-’ … instanceId … ‘-uncompressed.dcm’
local target = assert(io.open(uncompressed, ‘wb’))
target:write(dicom)
target:close()
– Compress to JPEG2000 using gdcm
local compressed = ‘/home/dicadmin/test-’ …instanceId … ‘-compressed.dcm’
os.execute('gdcmconv -U --jpeg ’ … uncompressed … ’ ’ … compressed)

– Generate a new SOPInstanceUID for the JPEG2000 file, as
– gdcmconv does not do this by itself
os.execute(‘dcmodify --no-backup -gin ’ … compressed)
– Read the JPEG2000 file
local source = assert(io.open(compressed, ‘rb’))
local jpeg2k = source:read(“*all”)
source:close()
– Upload the JPEG2000 file and remove the uncompressed file
RestApiPost(’/instances’, jpeg2k)
RestApiDelete(‘/instances/’ … instanceId)
– Remove the temporary DICOM files
os.remove(uncompressed)
os.remove(compressed)
end
if origin[‘RequestOrigin’] == ‘Lua’ then
PrintRecursive(origin)
SendToModality(instanceId, ‘dockero’)
end

end

`

If anyone has hint or has a suggestion for me to try it would be much appreciated. Thanks for your time

rduu9.txt (10.7 KB)

Since gdcmconv complains that it can not find the file, it looks like Orthanc fails to write the .dcm file in your folder.
You should check yourself if the files have been created.
You should also try to simply “touch” a file in that folder from your lua script to make sure Orthanc has access to that folder.

Hi,

Sorry for the late reply… I’m a bit lost about your /s1 folder which I don’t find in your original lua script.
At this point, I can only recommend you to execute system commands in your lua script to diagnose your problem (and print their output in lua so it appears in the logs).

You can use:

  • whoami to show which user orthanc is running
  • touch a test file in your folder
  • ls -al your folder content before and after your gdcm and dcmodify calls

That should bring you/us enough information to diagnose your issue.

Alain,

Thanks for your time with this matter. I thought I had posted my findings. It was my fault, the files I was trying to access were shared through smb, I did not check the permissions on those files.

Changed the permissions, and the script works just fine.

Have a good day.