Progress on this. This might actually work:
You’ll need these:
import io
from io import BytesIO
import zipfile
from zipfile
import ZipFile, ZipInfo
Intercept native method to enable logging, .zip archive
def OnDownloadStudyArchive(output, uri, **request):
orthanc.LogWarning(‘Creating Archive Bundled With Radiant Viewer’)
new_zip = BytesIO()
archive = orthanc.RestApiGet(uri)
‘/python/radiant_cd.zip’ is the location of the .zip archive for the Radiant CD/USB viewer, accessible from the script.
https://www.radiantviewer.com/dicom-viewer-manual/recording-dicom-cd_dvd.html
with ZipFile(‘/python/radiant_cd.zip’, ‘r’) as radiant_zip:
with ZipFile(new_zip, ‘w’) as new_archive:
for item in radiant_zip.filelist:
new_archive.writestr(item, radiant_zip.read(item.filename))
new_archive.writestr(‘archive.zip’, archive)
output.AnswerBuffer(new_zip.getvalue(), ‘application/zip’)
orthanc.RegisterRestCallback(‘/studies/(.*)/archive’, OnDownloadStudyArchive)
That generates an Archive named “Duck^Donald^Quack.zip” on my system, and when unzipped has the Radiant Viewer Files and a file called archive.zip.
In order to allow the viewer to work, you need to also extract the archive.zip file so it is unstuffed, probably after moving them to a USB, or before writing to a CD.
To open the Viewer (Windows OS only), launch it with ‘run’, or it might also autolaunch.
If you have a license file, that could be added to the reference radiant_cd.zip package on the server.
sscotti@Stephens-iMac Duck^Donald^Quack % ls -l
drwxr-xr-x@ 8 sscotti staff 256 Oct 1 10:00 COMMON
drwxr-xr-x@ 59 sscotti staff 1888 Aug 18 03:16 RA32
drwxr-xr-x@ 58 sscotti staff 1856 Aug 18 03:16 RA64
-rw-------@ 1 sscotti staff 9620397 Oct 19 05:20 archive.zip
-rw-r–r–@ 1 sscotti staff 200 Oct 19 2017 autorun.inf
-rw-r–r–@ 1 sscotti staff 2127 Nov 30 2017 readme.txt
-rw-r–r–@ 1 sscotti staff 37 Oct 19 2017 run.bat
Stephen D. Scotti