예제 #1
0
 def __init__(self,
              logs_path,
              cfg,
              www_path,
              move_path,
              user='',
              password=''):
     #WebServicesManager.__init__(self, user, password)
     self.logs_path = logs_path
     self.www_path = www_path
     self.move_path = move_path
     self.querys_state = None
     self.states_filename = path.join(self.logs_path, 'querys_state.db')
     xmlrpc.XMLRPC.__init__(self)
     self.allowNone = None
     self.cfg = cfg  # archivo de configuracion
     self.services = DicomServices()
     self.dicom_server = cfg.get("raddress", 'localhost')
     self.port = int(cfg.get("rport", 1104))
     self.called_aet = cfg.get("raet", 'IMGSVR')
     self.local_port = int(cfg.get("lport", 3000))
     self.calling_aet = cfg.get("aet", 'any')
     self.http_port = cfg.get("port", 80)
     self.hostname = os.uname()[
         1]  #"10.30.131.70" #!!! os.uname()[1] retorna el hostname
예제 #2
0
class WCFind(xmlrpc.XMLRPC):#WebServicesManager):
    '''Clase encargada de buscar en los servidores dicom locales.'''
    def __init__(self, logs_path, cfg, user='', password=''):
        #!!! WebServicesManager.__init__(self, user, password)
        self.logs_path = logs_path
        self.global_cache = path.join(logs_path, "global_search_cache")
        if not path.isdir(self.global_cache):
            os.mkdir(self.global_cache)
        xmlrpc.XMLRPC.__init__(self)
        self.allowNone = None
        self.cfg = cfg # archivo de configuracion
        self.services = DicomServices()
        self.dicom_server = cfg.get("raddress", 'localhost')
        self.port = int(cfg.get("rport", 1104))
        self.called_aet = cfg.get("raet", 'IMGSVR')
        self.local_port = int(cfg.get("lport", 3000))
        self.calling_aet = cfg.get("aet", 'any')   
        
    def xmlrpc_cfind(self, query_keys):
        print query_keys
        rsp_codes= {"find_response": 100,
                   "dicom_error": 101,
                   "service_error":102}
        dataset_dict_list = []
        try:
            try:
                self.services.connect(
                                      self.dicom_server, self.port,
                                      self.calling_aet, self.called_aet
                )
                keys_in_level, dataset_vector = self.services.cfind(query_keys)
                if dataset_vector:
                    while dataset_vector.size():
                        dataset = dataset_vector.pop()
                        dataset_dict_list.append(
                            self.services.convert_dataset_to_response(
                                        query_keys, 
                                        keys_in_level, dataset
                                    )
                            )
                
                    print dataset_dict_list
                    print "***********************************************\n"
                    print "All response: ", str(len(dataset_dict_list))
                    return [dataset_dict_list, rsp_codes["find_response"]]
                #else: error         
            except Exception, text_error:
                print text_error
                return ["Failed connect with dicom server", rsp_codes["dicom_error"]]

        except NoOptionError, textError:
            print textError
            print "Error: Check in file configuration " 
            return ["Wait some minutes for use this service.", rsp_codes["service_error"]] 
        except NoSectionError, textError:
            print textError
            print "Error: Check in file configuration " 
            return ["Wait some minutes for use this service.", rsp_codes["service_error"]]
예제 #3
0
 def __init__(self, logs_path, cfg, user='', password=''):
     #!!! WebServicesManager.__init__(self, user, password)
     self.logs_path = logs_path
     self.global_cache = path.join(logs_path, "global_search_cache")
     if not path.isdir(self.global_cache):
         os.mkdir(self.global_cache)
     xmlrpc.XMLRPC.__init__(self)
     self.allowNone = None
     self.cfg = cfg # archivo de configuracion
     self.services = DicomServices()
     self.dicom_server = cfg.get("raddress", 'localhost')
     self.port = int(cfg.get("rport", 1104))
     self.called_aet = cfg.get("raet", 'IMGSVR')
     self.local_port = int(cfg.get("lport", 3000))
     self.calling_aet = cfg.get("aet", 'any')   
예제 #4
0
 def __init__(self, logs_path, cfg, www_path, move_path, user='', password=''):
     #WebServicesManager.__init__(self, user, password)
     self.logs_path = logs_path
     self.www_path = www_path
     self.move_path = move_path
     self.querys_state = None
     self.states_filename = path.join(self.logs_path, 'querys_state.db') 
     xmlrpc.XMLRPC.__init__(self)
     self.allowNone = None
     self.cfg = cfg # archivo de configuracion
     self.services = DicomServices()
     self.dicom_server = cfg.get("raddress", 'localhost')
     self.port = int(cfg.get("rport", 1104))
     self.called_aet = cfg.get("raet", 'IMGSVR')
     self.local_port = int(cfg.get("lport", 3000))
     self.calling_aet = cfg.get("aet", 'any')
     self.http_port = cfg.get("port", 80) 
     self.hostname =  os.uname()[1]#"10.30.131.70" #!!! os.uname()[1] retorna el hostname
예제 #5
0
class MoveFilesXMLRPC(xmlrpc.XMLRPC):  #(WebServicesManager):
    def __init__(self,
                 logs_path,
                 cfg,
                 www_path,
                 move_path,
                 user='',
                 password=''):
        #WebServicesManager.__init__(self, user, password)
        self.logs_path = logs_path
        self.www_path = www_path
        self.move_path = move_path
        self.querys_state = None
        self.states_filename = path.join(self.logs_path, 'querys_state.db')
        xmlrpc.XMLRPC.__init__(self)
        self.allowNone = None
        self.cfg = cfg  # archivo de configuracion
        self.services = DicomServices()
        self.dicom_server = cfg.get("raddress", 'localhost')
        self.port = int(cfg.get("rport", 1104))
        self.called_aet = cfg.get("raet", 'IMGSVR')
        self.local_port = int(cfg.get("lport", 3000))
        self.calling_aet = cfg.get("aet", 'any')
        self.http_port = cfg.get("port", 80)
        self.hostname = os.uname()[
            1]  #"10.30.131.70" #!!! os.uname()[1] retorna el hostname

#===============================================================================
# Esta funcion codificara el comando en una clave. Siempre se generara la
# misma clave para el mismo comando, esa clave sera usada como nombre del fichero
# clave.db que contendra el registro de todas las imagenes pertenecientes a esa consulta.
#===============================================================================

    def query_encode(self, cmd):
        '''Esta funcion codifica el cmd en un numero entero.'''
        query_key = hash(str(cmd))
        return str(query_key)

    def xmlrpc_getUrls(self, cmd):
        ''' esta funcion retorna la lista de urls '''

        #              return ["http://*****:*****@localhost:2000 -I -q 00100020=07-6314 " + \
            "-q 0020000D=1.2.392.200036.9110.167138003.3361.20070904114115.0 -q 0020000E=1.2.392.200036.9110.167138003.2.20070904114237.0 -r 00080018"
            args = shlex.split(dcm_cmd)
            p = subprocess.Popen(args)
            sts = os.waitpid(
                p.pid,
                0)[1]  # sts es el estado de finalizacion del proceso dcmqr

        SopInstansUID_list = dcmfind_parser('/home/sackufpi/out.txt')
        return SopInstansUID_list

    def createFileNameList(self, filename):
        ''' Esta funcion es para probar.'''
        try:
            filenames_moved = []
            if path.isdir(filename):
                for root, dirs, files in os.walk(filename):
                    for name in files:
                        filename_moved = path.join(root, name)
                        filenames_moved.append(filename_moved)
            else:
                print "Invaliud directory or access deny exist: " + filename
                return None
            return filenames_moved
        except IOError, textError:
            print textError
예제 #6
0
class MoveFilesXMLRPC(xmlrpc.XMLRPC):#(WebServicesManager):

        def __init__(self, logs_path, cfg, www_path, move_path, user='', password=''):
            #WebServicesManager.__init__(self, user, password)
            self.logs_path = logs_path
            self.www_path = www_path
            self.move_path = move_path
            self.querys_state = None
            self.states_filename = path.join(self.logs_path, 'querys_state.db') 
            xmlrpc.XMLRPC.__init__(self)
            self.allowNone = None
            self.cfg = cfg # archivo de configuracion
            self.services = DicomServices()
            self.dicom_server = cfg.get("raddress", 'localhost')
            self.port = int(cfg.get("rport", 1104))
            self.called_aet = cfg.get("raet", 'IMGSVR')
            self.local_port = int(cfg.get("lport", 3000))
            self.calling_aet = cfg.get("aet", 'any')
            self.http_port = cfg.get("port", 80) 
            self.hostname =  os.uname()[1]#"10.30.131.70" #!!! os.uname()[1] retorna el hostname

#===============================================================================
# Esta funcion codificara el comando en una clave. Siempre se generara la 
# misma clave para el mismo comando, esa clave sera usada como nombre del fichero
# clave.db que contendra el registro de todas las imagenes pertenecientes a esa consulta.
#===============================================================================
        def query_encode(self, cmd):
            '''Esta funcion codifica el cmd en un numero entero.'''
            query_key = hash(str(cmd))
            return str(query_key)
          
        def xmlrpc_getUrls(self, cmd):
            ''' esta funcion retorna la lista de urls '''
            #              return ["http://*****:*****@localhost:2000 -I -q 00100020=07-6314 " + \
                "-q 0020000D=1.2.392.200036.9110.167138003.3361.20070904114115.0 -q 0020000E=1.2.392.200036.9110.167138003.2.20070904114237.0 -r 00080018"
                args = shlex.split(dcm_cmd) 
                p = subprocess.Popen(args)
                sts = os.waitpid(p.pid, 0)[1] # sts es el estado de finalizacion del proceso dcmqr
            
            SopInstansUID_list = dcmfind_parser('/home/sackufpi/out.txt')    
            return SopInstansUID_list
        
        def createFileNameList(self, filename):
            ''' Esta funcion es para probar.'''
            try:
                filenames_moved = []
                if path.isdir(filename):
                    for root, dirs, files in os.walk(filename):
                        for name in files:
                            filename_moved = path.join(root, name)
                            filenames_moved.append(filename_moved)
                else:
                    print "Invaliud directory or access deny exist: " + filename
                    return None
                return filenames_moved
            except IOError, textError:
                print textError