Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def onStateChanged(self, newState):
stdout, stderr = super(DICOMDirectorySender, self).onStateChanged(newState)
if stderr and stderr.size():
slicer.util.errorDisplay("An error occurred. For further information click 'Show Details...'",
windowTitle=self.__class__.__name__, detailedText=str(stderr))
return stdout, stderr
if "fingerprint" in result.keys():
# untrusted host -> ask to add to keystore
if slicer.util.confirmYesNoDisplay(
"{}\nDo you want to consider the following data as trusted in the future:\n{}".format(result['msg'], str(
result['fingerprint']))
):
host, port, fprint = result['fingerprint']
# write to SSLUtil
SSLUtil.fingerprintsLocal.update({fprint: {"port": port, "host": host}})
logic.writeFingerprintFile()
return True
return False
else:
# no connection to host
slicer.util.errorDisplay(result["msg"])
return False
return True
def run(self, inputFiberBundle, outputFiberBundle, fiberStepSize, fiberPercentage, fiberMinPoints, fiberMinLength, fiberMaxLength, enableScreenshots=0, advanced=0):
"""
Run the actual algorithm
"""
if not advanced:
if not self.isValidInputOutputData(inputFiberBundle, outputFiberBundle):
slicer.util.errorDisplay('Input fiberBundle is the same as output fiberBundle. Choose a different output fiberBundle.')
return False
logging.info('Processing started')
# Compute the thresholded output fiberBundle using the Threshold Scalar FiberBundle CLI module
#cliParams = {'InputFiberBundle': inputFiberBundle.GetID(), 'OutputFiberBundle': outputFiberBundle.GetID(), 'ThresholdValue' : fiberStepSize, 'ThresholdType' : 'Above'}
#cliNode = slicer.cli.run(slicer.modules.thresholdscalarfiberBundle, None, cliParams, wait_for_completion=True)
# access input data object
pd = inputFiberBundle.GetPolyData()
# create a new polydata to hold the output
outpd = vtk.vtkPolyData()
# log information about input
logging.info('Input Fiber Bundle Stats:')
logging.info(inputFiberBundle.GetName())
def unzipFileAndCopyToDirectory(self, filepath, copyToDirectory):
import zipfile
try:
zip_ref = zipfile.ZipFile(filepath, 'r')
destination = filepath.replace(os.path.basename(filepath), "")
logging.debug("extracting to %s " % destination)
zip_ref.extractall(destination)
zip_ref.close()
self.copyDirectory(filepath.replace(".zip", ""), copyToDirectory)
except zipfile.BadZipfile as exc:
if self.session.preopDICOMReceiver:
self.session.preopDICOMReceiver.hide()
slicer.util.errorDisplay("An error appeared while extracting %s. If the file is corrupt, please delete it and try "
"again." % filepath, detailedText=str(exc.message))
self.clearData()