Ejemplo n.º 1
0
 def start(self, incomingDir, onReceptionCallback, \
   storeSCPExecutable, storeSCPport, studyTimeout, \
   dcmqrSCPExecutable, dcmqrSCPConfigFile):
     self.incomingDir = incomingDir
     self.onReceptionCallback = onReceptionCallback
     self.storeSCPExecutable = storeSCPExecutable
     self.storeSCPport = storeSCPport
     self.studyTimeout = studyTimeout  #seconds
     self.dcmqrSCPExecutable = dcmqrSCPExecutable
     self.dcmqrSCPConfigFile = dcmqrSCPConfigFile
     # start the server!
     storeSCP_args = str(self.storeSCPport) + ' --eostudy-timeout ' + str(self.studyTimeout) \
         + ' --output-directory ' + self.incomingDir \
         + ' --sort-on-study-uid  \'\'' \
         + ' --exec-on-eostudy ' + self.onReceptionCallback
     dcmqrSCP_args = '--config ' + self.dcmqrSCPConfigFile
     storeSCP_retcode = super(DICOMListener,
                              self).start(self.storeSCPExecutable,
                                          storeSCP_args)
     dcmqrSCP_retcode = super(DICOMListener,
                              self).start(self.dcmqrSCPExecutable,
                                          dcmqrSCP_args)
     # set up logger
     logger.addHandler(getHandler(self.incomingDir.strip()))
     logger.info("Started storeSCP with these args: %s" % storeSCP_args)
     logger.info("Started dcmqrSCP with these args: %s" % dcmqrSCP_args)
     return storeSCP_retcode and dcmqrSCP_retcode
Ejemplo n.º 2
0
            sys.exit()
        elif opt in ("-c", "--dcm2xml"):
            dcm2xml_cmd = arg
        elif opt in ("-i", "--incoming"):
            incoming_dir = arg
        elif opt in ("-u", "--url"):
            url = arg
        elif opt in ("-e", "--email"):
            user_email = arg
        elif opt in ("-a", "--apikey"):
            apikey = arg
        elif opt in ("-d", "--dest"):
            dest_folder = arg

    # set up normal logger
    logger.addHandler(getHandler(incoming_dir.strip()))

    # log stdout and stderr during the period that received DICOM files are
    # processed in local disk and uploaded to Midas using Pydas
    stdout_logger.addHandler(getHandler(incoming_dir.strip()))
    out_log = StreamToLogger(stdout_logger, logging.INFO)
    sys.stdout = out_log
    stderr_logger.addHandler(getHandler(incoming_dir.strip()))
    err_log = StreamToLogger(stderr_logger, logging.ERROR)
    sys.stderr = err_log

    # move files to processing directory
    groupFilesbySeriesUID(dcm2xml_cmd, incoming_dir)

    # group files by SeriesInstanceUID
    processing_dir = os.path.join(incoming_dir, 'processing')
Ejemplo n.º 3
0
            incoming_dir = arg
        elif opt in ("-u", "--url"):
            url = arg
        elif opt in ("-e", "--email"):
            user_email = arg
        elif opt in ("-a", "--apikey"):
            apikey = arg
        elif opt in ("-d", "--dest"):
            dest_folder = arg
        elif opt in ("-q", "--dcmqrscp"):
            dcmqrscp_cmd = arg
        elif opt in ("-f", "--qrscpcfg"):
            dcmqrscp_cfg = arg

    # set up logger
    logger.addHandler(getHandler(incoming_dir.strip()))

    # start/stop dicom server
    myListener = DICOMListener()
    if start:
        # callback command used by storescp '--eostudy-timeout' option
        callback_cmd = "'python %s -c %s -i %s -u %s -e %s -a %s -d %s'" % ( \
          script_path, dcm2xml_cmd, incoming_dir, url, user_email, apikey, dest_folder)
        logger.info("Starting DICOM listener ...")
        retcode = myListener.start(incoming_dir, callback_cmd, \
          storescp_cmd, storescp_port, storescp_timeout, \
          dcmqrscp_cmd, dcmqrscp_cfg)
        return retcode
    else:
        if not storescp_cmd:
            storescp_cmd = 'storescp'
Ejemplo n.º 4
0
            incoming_dir = arg
        elif opt in ("-u", "--url"):
            url = arg
        elif opt in ("-e", "--email"):
            user_email = arg
        elif opt in ("-a", "--apikey"):
            apikey = arg
        elif opt in ("-d", "--dest"):
            dest_folder = arg
        elif opt in ("-q", "--dcmqrscp"):
            dcmqrscp_cmd = arg
        elif opt in ("-f", "--qrscpcfg"):
            dcmqrscp_cfg = arg

    # set up logger
    logger.addHandler(getHandler(incoming_dir.strip()))

    # start/stop dicom server
    myListener = DICOMListener()
    if start:
        # callback command used by storescp '--eostudy-timeout' option
        callback_cmd = "'python %s -c %s -i %s -u %s -e %s -a %s -d %s'" % ( \
          script_path, dcm2xml_cmd, incoming_dir, url, user_email, apikey, dest_folder)
        logger.info("Starting DICOM listener ...")
        retcode = myListener.start(incoming_dir, callback_cmd, \
          storescp_cmd, storescp_port, storescp_timeout, \
          dcmqrscp_cmd, dcmqrscp_cfg)
        return retcode
    else:
        if not storescp_cmd:
            storescp_cmd = 'storescp'