Example #1
0
 def handle_all_proposes(self, proposes):
     FipaContractNetProtocol.handle_all_proposes(self, proposes)
     
     try:
         
         self.bestPropose = proposes[0]
         
         for propose in proposes:
             content = loads(propose.content)
             if content['how much is'] < loads(self.bestPropose.content)['how much is']:
                 self.bestPropose = propose
                 
         response = self.bestPropose.create_reply()
         response.set_performative(ACLMessage.ACCEPT_PROPOSAL)
         response.set_content('Propostal Accepted')
         self.agent.send(response)
         
         for propose in proposes:
             if propose != self.bestPropose:
                 response = propose.create_reply()
                 response.set_performative(ACLMessage.REJECT_PROPOSAL)
                 response.set_content('Proposal Rejected')
                 self.agent.send(response)
     except:
         display_message(self.agent.aid.name, 'Unable to process because no message has returned.')
Example #2
0
 def handle_accept_propose(self, message):
     FipaContractNetProtocol.handle_accept_propose(self, message)
     response = message.create_reply()
     response.set_performative(ACLMessage.INFORM)
     response.set_content('RECOMPOSICAO AUTORIZADA')
     self.agent.send(response)
     display_message(self.agent.aid.name, message.content)
    def handle_all_proposes(self, proposes):
        FipaContractNetProtocol.handle_all_proposes(self, proposes)

        try:

            self.bestPropose = proposes[0]

            for propose in proposes:
                content = loads(propose.content)
                if content["how much is"] < loads(self.bestPropose.content)["how much is"]:
                    self.bestPropose = propose

            response = self.bestPropose.create_reply()
            response.set_performative(ACLMessage.ACCEPT_PROPOSAL)
            response.set_content("Proposta Aceita")
            self.agent.send(response)

            for propose in proposes:
                if propose != self.bestPropose:
                    response = propose.create_reply()
                    response.set_performative(ACLMessage.REJECT_PROPOSAL)
                    response.set_content("Proposta Recusada")
                    self.agent.send(response)
        except:
            display_message(
                self.agent.aid.name, "O Processamento não foi possivel porque nenhuma mensagem foi retornada."
            )
Example #4
0
    def handle_all_proposes(self, proposes):
        FipaContractNetProtocol.handle_all_proposes(self, proposes)

        try:

            self.bestPropose = proposes[0]

            for propose in proposes:
                content = loads(propose.content)
                if content['how much is'] < loads(
                        self.bestPropose.content)['how much is']:
                    self.bestPropose = propose

            response = self.bestPropose.create_reply()
            response.set_performative(ACLMessage.ACCEPT_PROPOSAL)
            response.set_content('Proposta Aceita')
            self.agent.send(response)

            for propose in proposes:
                if propose != self.bestPropose:
                    response = propose.create_reply()
                    response.set_performative(ACLMessage.REJECT_PROPOSAL)
                    response.set_content('Proposta Recusada')
                    self.agent.send(response)
        except:
            display_message(
                self.agent.aid.name,
                'O Processamento não foi possivel porque nenhuma mensagem foi retornada.'
            )
Example #5
0
 def handle_accept_propose(self, message):
     FipaContractNetProtocol.handle_accept_propose(self, message)
     response = message.create_reply()
     response.set_performative(ACLMessage.INFORM)
     response.set_content('RECOMPOSICAO AUTORIZADA')
     self.agent.send(response)
     display_message(self.agent.aid.name, message.content)
Example #6
0
def call_converter(args, version='1.0'):
    script, package_path, collection_acron = xml_converter_get_inputs(args)
    if package_path is None and collection_acron is None:
        # GUI
        import xml_gui
        xml_gui.open_main_window(True, None)

    elif package_path is not None and collection_acron is not None:
        errors = xml_converter_validate_inputs(package_path, collection_acron)
        if len(errors) > 0:
            messages = []
            messages.append('\n===== ' + _('ATTENTION') + ' =====\n')
            messages.append(validation_status.STATUS_ERROR + ': ' + _('Incorrect parameters'))
            messages.append('\n' + _('Usage') + ':')
            messages.append('python xml_converter.py <xml_folder> | <collection_acron>')
            messages.append(_('where') + ':')
            messages.append('  <xml_folder> = ' + _('path of folder which contains'))
            messages.append('  <collection_acron> = ' + _('collection acron'))
            messages.append('\n'.join(errors))
            utils.display_message('\n'.join(messages))
        else:
            execute_converter(package_path, collection_acron)
    elif collection_acron is not None:
        execute_converter(package_path, collection_acron)
    elif package_path is not None:
        execute_converter(package_path)
Example #7
0
    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'Uma mensagem recebida')

        if 'agente_teste_participante' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Ola tambem agente!')
            self.send(resposta)
Example #8
0
    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'One message received')

        if 'test_agent_participant' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Hello to you too, Agent!')
            self.send(resposta)
Example #9
0
 def handle_cfp(self, message):
     FipaContractNetProtocol.handle_cfp(self, message)
     
     display_message(self.agent.aid.name, loads(message.content))
     response = message.create_reply()
     response.set_performative(ACLMessage.PROPOSE)
     response.set_content(dumps(self.power_values))
     self.agent.send(response)
Example #10
0
    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'Uma mensagem recebida')

        if 'agente_teste_participante' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Ola tambem agente!')
            self.send(resposta)
Example #11
0
    def handle_cfp(self, message):
        FipaContractNetProtocol.handle_cfp(self, message)

        display_message(self.agent.aid.name, loads(message.content))
        response = message.create_reply()
        response.set_performative(ACLMessage.PROPOSE)
        response.set_content(dumps(self.power_values))
        self.agent.send(response)
Example #12
0
    def handle_accept_propose(self, message):
        FipaContractNetProtocol.handle_accept_propose(self, message)

        display_message(self.agent.aid.name, 'Proposal Accepted')

        response = message.create_reply()
        response.set_performative(ACLMessage.INFORM)
        response.set_content('Purchase Approved')
        self.agent.send(response)
Example #13
0
    def handle_accept_propose(self, message):
        FipaContractNetProtocol.handle_accept_propose(self, message)

        display_message(self.agent.aid.name, 'Proposta Aceita')

        response = message.create_reply()
        response.set_performative(ACLMessage.INFORM)
        response.set_content('Compra Autorizada')
        self.agent.send(response)
Example #14
0
 def handle_accept_propose(self, message):
     FipaContractNetProtocol.handle_accept_propose(self, message)
     
     display_message(self.agent.aid.name, 'Proposta Aceita')
     
     response = message.create_reply()
     response.set_performative(ACLMessage.INFORM)
     response.set_content('Compra Autorizada')
     self.agent.send(response)
Example #15
0
    def on_start(self):
        Agent.on_start(self)
        display_message(self.aid.name, "Hello World")

        if 'agente_teste_iniciante' in self.aid.name:
            message = ACLMessage(ACLMessage.INFORM)
            message.add_receiver('agente_teste_participante')
            message.set_content('Ola Agente!')
            self.send(message)
            display_message(self.aid.name, 'Enviando mensagem...')
Example #16
0
    def on_start(self):
        Agent.on_start(self)
        display_message(self.aid.name, "Hello World")

        if 'test_agent_initiator' in self.aid.name:
            message = ACLMessage(ACLMessage.INFORM)
            message.add_receiver('test_agent_participant')
            message.set_content('Hello Agent!')
            self.send(message)
            display_message(self.aid.name, 'Sending Message...')
Example #17
0
    def on_start(self):
        Agent.on_start(self)
        display_message(self.aid.name, "Hello World")

        if 'agente_teste_iniciante' in self.aid.name:
            message = ACLMessage(ACLMessage.INFORM)
            message.add_receiver('agente_teste_participante')
            message.set_content('Ola Agente!')
            self.send(message)
            display_message(self.aid.name, 'Enviando mensagem...')
Example #18
0
	def handle_request(self, message):
		display_message(self.agent.aid.name, message.content)
		
		response = message.create_reply()
		response.set_performative(ACLMessage.AGREE)
		response.set_content('AGREE')
		self.agent.send(response)
		
		response_2 = message.create_reply()
		response_2.set_performative(ACLMessage.INFORM)
		response_2.set_content('INFORM')
		self.agent.send(response_2)
Example #19
0
	def handle_request(self, message):
		display_message(self.agent.aid.name, message.content)
		
		response = message.create_reply()
		response.set_performative(ACLMessage.AGREE)
		response.set_content('AGREE')
		self.agent.send(response)
		
		response_2 = message.create_reply()
		response_2.set_performative(ACLMessage.INFORM)
		response_2.set_content('INFORM')
		self.agent.send(response_2)
Example #20
0
 def react(self, message):
     
     if message.performative == ACLMessage.PROPOSE or message.performative == ACLMessage.REJECT_PROPOSAL:
         self.receives += 1
         self.messages.append(message)
         display_message(self.aid.name, 'Received Proposal')
         print str(loads(message.content))
     
     if self.receives == self.sends:
         message = self.analisys()
         display_message(self.aid.name, 'Best Proposal Selected:')
         propose = loads(message.content)
         print str(propose)
Example #21
0
 def react(self, message):
     
     if message.performative == ACLMessage.PROPOSE or message.performative == ACLMessage.REJECT_PROPOSAL:
         self.receives += 1
         self.messages.append(message)
         display_message(self.aid.name, 'Received Propose')
         print str(loads(message.content))
     
     if self.receives == self.sends:
         message = self.analisys()
         display_message(self.aid.name, 'Best Propose Selected:')
         propose = loads(message.content)
         print str(propose)
Example #22
0
 def handle_cfp(self, message):
     FipaContractNetProtocol.handle_cfp(self, message)
     display_message(self.agent.aid.name, 'Solicitação Recebida')
     
     pedido = loads(message.content)
     
     for book in self.agent.booksList:
         if book['title'] == pedido['title'] and book['author'] == pedido['author']:
             if book['qtd'] >= pedido['qtd']:
                 response = message.create_reply()
                 response.set_performative(ACLMessage.PROPOSE)
                 book['book store'] = self.agent.aid.name
                 response.set_content(dumps(book))
                 self.agent.send(response)
             else:
                 response = message.create_reply()
                 response.set_performative(ACLMessage.REJECT_PROPOSAL)
                 response.set_content('Requisição Recusada')
                 self.agent.send(response)
Example #23
0
 def handle_cfp(self, message):
     FipaContractNetProtocol.handle_cfp(self, message)
     display_message(self.agent.aid.name, 'Request Received')
     
     order = loads(message.content)
     
     for book in self.agent.booksList:
         if book['title'] == order['title'] and book['author'] == order['author']:
             if book['qty'] >= order['qty']:
                 response = message.create_reply()
                 response.set_performative(ACLMessage.PROPOSE)
                 book['book store'] = self.agent.aid.name
                 response.set_content(dumps(book))
                 self.agent.send(response)
             else:
                 response = message.create_reply()
                 response.set_performative(ACLMessage.REJECT_PROPOSAL)
                 response.set_content('Request Rejected')
                 self.agent.send(response)
Example #24
0
    def handle_cfp(self, message):
        FipaContractNetProtocol.handle_cfp(self, message)
        display_message(self.agent.aid.name, 'Solicitação Recebida')

        pedido = loads(message.content)

        for book in self.agent.booksList:
            if book['title'] == pedido['title'] and book['author'] == pedido[
                    'author']:
                if book['qtd'] >= pedido['qtd']:
                    response = message.create_reply()
                    response.set_performative(ACLMessage.PROPOSE)
                    book['book store'] = self.agent.aid.name
                    response.set_content(dumps(book))
                    self.agent.send(response)
                else:
                    response = message.create_reply()
                    response.set_performative(ACLMessage.REJECT_PROPOSAL)
                    response.set_content('Requisição Recusada')
                    self.agent.send(response)
Example #25
0
    def make_request(self, title, tile):
        # Calls the appropriate downloader based on the selected site and starts a thread to prevent kivy event loop from locking
        download_thread_target = partial(
            self.downloader_links_methods.get(self.master.downloader), tile,
            title, self.manga_data.get(title))
        download_thread = Thread(name=f"Download Thread {title}",
                                 target=download_thread_target)

        # Flag used to ensure that the same manga is not downloaded while it is already being downloaded
        if self.master.download_threads.get(
                title, None
        ) == None:  # If a manga is already being downloaded it will not return None
            self.master.download_threads.update({title: download_thread})
            self.master.currently_downloading = True
            tile.progressbar.opacity = 1

            # Creates the directory for that manga within the manga root and changes to it
            create_manga_dirs(self.master.downloader, title)
            download_thread.start()
        else:
            display_message(f"{title} is already downloading")
Example #26
0
    def handle_all_proposes(self, proposes):
        FipaContractNetProtocol.handle_all_proposes(self, proposes)

        display_message(self.agent.aid.name, 'Analisando Propostas...')
        better_propose = loads(proposes[0].content)
        better_propositor = proposes[0]
        for propose in proposes:
            power_value = loads(propose.content)
            if power_value['value'] > better_propose['value']:
                better_propose = power_value
                better_propositor = propose

        response_1 = better_propositor.create_reply()
        response_1.set_performative(ACLMessage.ACCEPT_PROPOSAL)
        response_1.set_content('Proposta ACEITA')
        self.agent.send(response_1)

        for propose in proposes:
            if propose != better_propositor:
                response = propose.create_reply()
                response.set_performative(ACLMessage.REJECT_PROPOSAL)
                response.set_content('Proposta RECUSADA')
                self.agent.send(response)
Example #27
0
 def handle_all_proposes(self, proposes):
     FipaContractNetProtocol.handle_all_proposes(self, proposes)
     
     display_message(self.agent.aid.name, 'Analisando Propostas...')
     better_propose = loads(proposes[0].content)
     better_propositor = proposes[0]
     for propose in proposes:
         power_value = loads(propose.content)
         if power_value['value'] > better_propose['value']:
             better_propose = power_value
             better_propositor = propose
     
     response_1 = better_propositor.create_reply()
     response_1.set_performative(ACLMessage.ACCEPT_PROPOSAL)
     response_1.set_content('Proposta ACEITA')
     self.agent.send(response_1)
     
     for propose in proposes:
         if propose != better_propositor:
             response = propose.create_reply()
             response.set_performative(ACLMessage.REJECT_PROPOSAL)
             response.set_content('Proposta RECUSADA')
             self.agent.send(response)
Example #28
0
def call_execute_pubmed_procedures(args):

    script, issue_path, from_date, final_date, debug = read_inputs(args)

    if issue_path is None:
        # GUI
        issue_path, from_date = read_form_inputs()
        script = 'exit'
        final_date = utils.now()[0]
        debug = False

    errors = []
    if issue_path is None and script != 'exit':
        errors.append('ERROR: ' + _('Incorrect parameters'))
        errors.append('\n' + _('Usage') + ':')
        errors.append('python ' + script + ' <issue_path>')
        errors.append(_('where') + ':')
        errors.append('  <issue_path> = ' + _('issue folder in serial folder'))

    if not os.path.isdir(issue_path):
        errors.append(_('issue path is not a folder'))

    if len(errors) == 0:
        config = xc_config.XMLConverterConfiguration(CURRENT_PATH + '/../../scielo_paths.ini')
        ucisis = dbm_isis.UCISIS(dbm_isis.CISIS(config.cisis1030), dbm_isis.CISIS(config.cisis1660))

        if ucisis.is_available:
            issue_stuff = IssueStuff(ucisis, issue_path, from_date, final_date)

            pubmed_xml_maker = PubMedXMLMaker(issue_stuff, CURRENT_PATH + '/../../pmc/v3.0/xsl/xml2pubmed/xml2pubmed.xsl')
            pubmed_xml_maker.debug = debug
            pubmed_xml_maker.execute_procedures()
        else:
            errors.append(_('cisis expected'))

    if len(errors) > 0:
        utils.display_message('\n'.join(errors))
Example #29
0
def game():
    intro = True
    while intro:
        gameDisplay.fill(BLACK)
        display_message("Space Invaders", BLUE, 180, 150, 70)
        display_message("Press P to Play and Q to Exit", GREEN, 180, 250, 30)
        display_message("Use A and D to move the SpaceShip", GREEN, 180, 280,
                        30)
        display_message("S and Space Bar will launch missiles", GREEN, 180,
                        310, 30)
        pygame.display.update()
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_p:
                    intro = False
                    main_loop()
                elif event.key == pygame.K_q:
                    pygame.quit()
                    quit()
Example #30
0
	def handle_inform(self, message):
		display_message(self.agent.aid.name, message.content)
Example #31
0
 def handle_reject_proposes(self, message):
     FipaContractNetProtocol.handle_reject_proposes(self, message)
     display_message(self.agent.aid.name, message.content)
Example #32
0
 def react(self, message):
     display_message(self.aid.name, 'Received Purchase Order')
     self.message = message
     if message.performative == ACLMessage.CALL_FOR_PROPOSAL:
         self.pedido = loads(message.content)
         self.analisys(self.pedido)
Example #33
0
    def accept(self):
        '''
        This will handle the actions once the user wants to process
        the images.
        '''
        # make sure they entered an identifier
        if not len(self.user_id_line_edit.text()) > 0:
            # display error message
            message = "Please enter a new patient identifier."
            utils.display_gui_message(self, "No indentification entered.", message)
            return

        # get the image numbers that the user entered
        image_num_wanted = \
              parselist.parse_list_reg_exp(self.num_images_line_edit.text())

        # get the filenames for the images
        image_name_wanted = []
        utils.display_message("%s files wanted..." % len(image_num_wanted))
        for num in image_num_wanted:
            try:
                # we allow users to enters image numbers starting 
                # at 1, so we need to get them back to base-zero 
                # so, subtract one
                image_name_wanted.append(self.dicom_image_name_list[num-1])
                utils.display_message("File index %s\t : Orig filename %s" %\
                                     (num, self.dicom_image_name_list[num-1]))
            except Exception as msg:
                message = "Invalid range of images wanted, image %s not in image stack" %(num)
                utils.display_message("%s" % message)
                utils.display_gui_message(self, "Invalid range of images", message)
                self.set_num_images(len(self.dicom_image_name_list))
                return


        # Set up the progress bar
        # Can't get this to work as needed
        #progress = QtGui.QProgressDialog("de-identifying files...", 
        #                                 "Abort", 
        #                                 100, 
        #                                 100, 
        #                                 self)

        #progress.setMinimumDuration(0)
        #progress.setWindowModality(QtCore.Qt.WindowModal)
        ##progress.forceShow()
        ##progress.open()
        ##progress.setVisible(True)
        ##progress.setRange(0,1)
        #progress.setValue(0)
        #progress.setRange(0,0)
        #progress.show()

        t0 = time.time()
        # now process the images
        #QtGui.qApp.processEvents() # this would get the bar to display, just not move
        self.process_image = ProcessDicom(self.existing_directory_label.text(),
                                     self.new_directory_label.text(),
                                     image_name_wanted,
                                     image_num_wanted,
                                     self.user_id_line_edit.text(),
                                     self.memory_line_edit.text())

        result = self.process_image.process()

        if not result:
            message = 'De-identification completed with issues, see console.'
            gui_message = 'De-identification completed <b>with issues</b>, see console.'
        else:
            message = 'De-identification completed successfully.'
            gui_message = 'De-identification completed <b>successfully.</b>'

        ##progress.done()
        ##progress.finished()
        ##progress.update()
        #progress.cancel()

        t1 = time.time()
        utils.display_message("Total process time: %s seconds" % (t1 - t0))

        # Let the user know we're done with this batch
        utils.display_message(message)
        utils.display_gui_message(self, "De-identification Notice.", gui_message)
Example #34
0
	def handle_inform(self, message):
		display_message(self.agent.aid.name, message.content)
Example #35
0
            if estimators is None:
                this_one = utils.filepath(*feat_args)
            else:
                for clf, _ in estimators:
                    res_args = feat_args + [clf.__name__]
                    this_one = utils.filepath(*res_args)



    datasets, descriptors, estimators = loops
    utils.display_sequence(datasets, 'Datasets', symbol='-')
    utils.display_sequence(descriptors, 'Descriptors', symbol='-')
    utils.display_sequence(
        [est[0].__name__ for est in estimators], 'Classifiers', symbol='-')

    utils.display_message('Creating arguments file and job script', symbol='*')

    tasks = command_line_arguments(data, loops)
    count = len(tasks)

    if count == 0:
        print('All tasks are already completed. Did not generate script.\n')
    else:
        args_file = 'args_{}.config'.format(job_id)
        save_args_file(args_file, tasks)
        job_file = 'job_{}.sh'.format(job_id)
        if partition == 'cola-corta':
            time_limit = '10:00:00'
            max_ntasks = 48
        elif partition == 'thinnodes':
            time_limit = '4-00:00:00'
Example #36
0
 def handle_inform(self, message):
     FipaContractNetProtocol.handle_inform(self, message)
     display_message(self.agent.aid.name, message.content)
 def handle_inform(self, message):
     FipaContractNetProtocol.handle_inform(self, message)
     display_message(self.agent.aid.name, "Compra Autorizada")
Example #38
0
 def handle_refuse(self, message):
     FipaContractNetProtocol.handle_refuse(self, message)
     display_message(self.agent.aid.name, loads(message.content))
 def handle_propose(self, message):
     FipaContractNetProtocol.handle_propose(self, message)
     display_message(self.agent.aid.name, "Proposta Recebida")
Example #40
0
from messages import ACLMessage
from aid import AID
from pickle import dumps, loads
from time import sleep



class Teste(Agent):
	def __init__(self, aid):
		Agent.__init__(self, aid)
		
	def on_start
on_start(self):
		Agent.on_start
on_start(self)
		display_message(self.aid.name, "Hello World")
		if 'Bob' in self.aid.name:
			message = ACLMessage(ACLMessage.INFORM)
			message.add_receiver(AID('Alice'))
			message.set_content('Ola Alice!')
			self.send(message)
	
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())

if __name__ == '__main__':
	set_ams('localhost', 8000)
	
	agente = Teste(AID('Alice'))
	agente.set_ams('localhost', 8000)
Example #41
0
def generate_latex(args):
    ''' !!! Missing docstring.'''

    def get_max_val(lst):
        ''' !!! Missing docstring.'''
        flattened = []
        for item in lst:
            if isinstance(item, (int, float)):
                flattened.append(item)
            elif isinstance(item, list):
                flattened.extend(item)
        return max(flattened) if flattened else None

    # Load settings
    dbtex, imdescr = load_settings(args, config.IMGS)

    # Display information
    utils.display_sequence(dbtex, 'Datasets', symbol='-')
    utils.display_sequence(imdescr, 'Descriptors', symbol='-')
    utils.display_sequence(
        [est[0].__name__ for est in config.ESTIMATORS],
        'Classifiers', symbol='-')
    utils.display_message('Generating LaTeX code', symbol='*')

    # Generate introductory sections
    code = introduction_validation(
        config.DATA, config.N_TESTS, config.TEST_SIZE, config.N_FOLDS)
    code += introduction_classifiers(config.ESTIMATORS)
    code += introduction_dimensions(imdescr)
    code += introduction_parameters()
    code = [code]


    # `sects`: names of the used descriptors (sorted alphabetically)
    sections = sorted(set(d.__class__.__name__ for d in imdescr))

#    # !!! Refactoring required
    for s in sections:
        # `s`: section title (is a descriptor name)
        code.append(r'\section*{{{0}}}'.format(s))
        tups = [tuple(d.radius) for d in imdescr if d.__class__.__name__ == s]
        # `rlst`: radii considered for descriptor `s`
        rlst = [*map(list, sorted(set(tups), key=lambda x: (len(x), x)))]
        # `osect`: orders considered for descriptor `s`
        #osect = sorted(set(d.order for d in imdescr if d.__class__.__name__ == s), key=lambda x: len(x))
        osect = hep._orders
        for k, (clf, params) in enumerate(config.ESTIMATORS):
            if k > 0:
                code.append(r'\newpage')
            code.append(r'\subsection*{{{0}}}'.format(clf.__name__))
            code.append(r'\begin{{longtable}}{{ll{0}}}'.format('r'*len(osect)))
            heading = r' & '.join([o.capitalize() for o in osect])
            code.append(r'Dataset & Radius & {0} \\'.format(heading))
            code.append(r'\hline')
            for db in dbtex:
                for i, r in enumerate(rlst):
                    if i == 0:
                        line = r'{0} & {1} '.format(db, r)
                    else:
                        line = r' & {0} '.format(r)
                    vals = []
                    for o in osect:
                    #for o in hep._orders:
                        # `same`: list of descriptors with the same name, radius and order
                        same = [d for d in imdescr if d.__class__.__name__ == s and d.radius == r and d.order == o]
                        if not same:
                            #print('Not required:  {}--{}--{}--{}--{}'.format(db, s, r, o, clf.__name__))
                            vals.append(None)
                        elif len(same) == 1:
                            result_path = utils.filepath(config.DATA, db, same[0], clf)
                            if os.path.isfile(result_path):
                                #print('Reading single:  ', result_path)
                                result = utils.load_object(result_path)
                                acc = 100*np.mean([ts for g, ts in result])
                                vals.append(acc)
                            else:
                                print('Not found (single):  ', result_path)
                                vals.append(None)
                        else:
                            accs = []
                            for descr in same:
                                result_path = utils.filepath(config.DATA, db, descr, clf)
                                if os.path.isfile(result_path):
                                    #print('Reading multiple:  ', result_path)
                                    result = utils.load_object(result_path)
                                    accs.append(100*np.mean([ts for g, ts in result]))
                                else:
                                    print('Not found (multi):  ', result_path)
                            if not accs:
                                vals.append(None)
                            elif len(accs) == 1:
                                vals.append(accs[0])
                            elif len(accs) > 1:
                                vals.append([np.min(accs), np.max(accs)])
                    for v in vals:
                        maxval = get_max_val(vals)
                        if v is None:
                            line += r'& '
                        elif isinstance(v, (int, float)):
                            if v == maxval:
                                line += r'& \bfseries{{{0:.1f}}} '.format(v)
                            else:
                                line += r'& {0:.1f} '.format(v)
                        elif isinstance(v, list):
                            if v[1] == maxval:
                                line += r'& \bfseries{{{0:.1f}--{1:.1f}}} '.format(v[0], v[1])
                            else:
                                line += r'& {0:.1f}--{1:.1f} '.format(v[0], v[1])
                    line += r'\\'
                    code.append(line)

            code.append(r'\end{longtable}')

        code.append(r'\newpage')
    code.append(r'\end{document}')

    latex_path = os.path.join(config.DATA, 'results.tex')
    with open(latex_path, 'w') as fid:
        fid.write('\n'.join(code))
Example #42
0
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())
Example #43
0
def execute_converter(package_paths, collection_name=None):
    collection_names = {}
    collection_acron = collection_names.get(collection_name)
    if collection_acron is None:
        collection_acron = collection_name

    config = xc.get_configuration(collection_acron)
    if config is not None:
        prepare_env(config)
        invalid_pkg_files = []

        mailer = xc.get_mailer(config)

        if package_paths is None:
            package_paths, invalid_pkg_files = queue_packages(config.download_path, config.temp_path, config.queue_path, config.archive_path)
        if package_paths is None:
            package_paths = []
        if not isinstance(package_paths, list):
            package_paths = [package_paths]

        for package_path in package_paths:
            package_folder = os.path.basename(package_path)
            utils.display_message(package_path)
            scilista_items = []
            xc_status = 'interrupted'
            stats_msg = ''
            report_location = None

            try:
                scilista_items, xc_status, stats_msg, report_location = convert_package(package_path)
            except Exception as e:
                if config.queue_path is not None:
                    fs_utils.delete_file_or_folder(package_path)
                if config.email_subject_invalid_packages is not None:
                    send_message(mailer, config.email_to_adm, '[Step 1]' + config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n' + package_folder + '\n' + str(e))
                if len(package_paths) == 1:
                    raise
            print(scilista_items)
            try:
                acron, issue_id = scilista_items[0].split(' ')

                if xc_status in ['accepted', 'approved']:
                    if config.collection_scilista is not None:
                        open(config.collection_scilista, 'a+').write('\n'.join(scilista_items) + '\n')

                    if config.is_enabled_transference:
                        transfer_website_files(acron, issue_id, config.local_web_app_path, config.transference_user, config.transference_servers, config.remote_web_app_path)

                if report_location is not None:
                    if config.email_subject_package_evaluation is not None:
                        results = ' '.join(EMAIL_SUBJECT_STATUS_ICON.get(xc_status, [])) + ' ' + stats_msg
                        link = config.web_app_site + '/reports/' + acron + '/' + issue_id + '/' + os.path.basename(report_location)
                        report_location = '<html><body>' + html_reports.link(link, link) + '</body></html>'

                        transfer_report_files(acron, issue_id, config.local_web_app_path, config.transference_user, config.transference_servers, config.remote_web_app_path)
                        send_message(mailer, config.email_to, config.email_subject_package_evaluation + u' ' + package_folder + u': ' + results, report_location)

            except Exception as e:
                if config.email_subject_invalid_packages is not None:
                    send_message(mailer, config.email_to_adm, '[Step 2]' + config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n' + package_folder + '\n' + str(e))

                if len(package_paths) == 1:
                    print('exception as finishing')
                    raise

        if len(invalid_pkg_files) > 0:
            if config.email_subject_invalid_packages is not None:
                send_message(mailer, config.email_to, config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n'.join(invalid_pkg_files))

    utils.display_message(_('finished'))
Example #44
0
 def handle_refuse(self, message):
     FipaContractNetProtocol.handle_refuse(self, message)
     display_message(self.agent.aid.name, loads(message.content))
Example #45
0
 def handle_inform(self, message):
     FipaContractNetProtocol.handle_inform(self, message)
     display_message(self.agent.aid.name, 'Purchase Approved')
Example #46
0
 def handle_propose(self, message):
     FipaContractNetProtocol.handle_propose(self, message)
     display_message(self.agent.aid.name, 'Proposta Recebida')
Example #47
0
 def react(self, message):
     display_message(self.aid.name, 'Received Purchase Order')
     self.message = message
     if message.performative == ACLMessage.CALL_FOR_PROPOSAL:
         self.order = loads(message.content)
         self.analisys(self.order)
Example #48
0
from messages import ACLMessage
from aid import AID
from pickle import dumps, loads
from time import sleep



class Teste(Agent):
	def __init__(self, aid):
		Agent.__init__(self, aid)
		
	def on_start
on_start(self):
		Agent.on_start
on_start(self)
		display_message(self.aid.name, "Hello World")
		if 'Bob' in self.aid.name:
			message = ACLMessage(ACLMessage.INFORM)
			message.add_receiver(AID('Alice'))
			message.set_content('Hello Alice!')
			self.send(message)
	
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())

if __name__ == '__main__':
	set_ams('localhost', 8000)
	
	agente = Teste(AID('Alice'))
	agente.set_ams('localhost', 8000)
Example #49
0
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())
Example #50
0
 def handle_inform(self, message):
     FipaContractNetProtocol.handle_inform(self, message)
     display_message(self.agent.aid.name, 'Compra Autorizada')
Example #51
0
 def handle_inform(self, message):
     FipaContractNetProtocol.handle_inform(self, message)
     display_message(self.agent.aid.name, message.content)
Example #52
0
    def handle_reject_proposes(self, message):
        FipaContractNetProtocol.handle_reject_proposes(self, message)

        display_message(self.agent.aid.name, 'Proposal Rejected')
Example #53
0
 def handle_reject_proposes(self, message):
     FipaContractNetProtocol.handle_reject_proposes(self, message)
     
     display_message(self.agent.aid.name, 'Proposta Recusada')