Esempio n. 1
0
    def on_ProcessToolBar_clickedIneer(self):
        t_nPage = self.widgets['WorkArea'].get_current_page()
        t_bIsLive = False
        if self.m_oGcDiagrams.has_key(t_nPage):
            self.UpdateStatus(0)

            t_oGcDiagram = self.m_oGcDiagrams[t_nPage]
            t_oProcessXML = xmltree.xmlTree()
            t_oProcessXML.fromString("<harpia>" +
                                     str(t_oGcDiagram.GetProcessChain()) +
                                     "</harpia>")
            assert t_oProcessXML.isValid(), 'invalid process chain: %r'

            if t_oProcessXML.findAttributes('./properties/block'):
                # if harpia/properties is not empty

                #cpscotti standalone!!!
                t_lsProcessChain = [
                ]  #lista pra n precisar ficar copiando prum lado e pro otro o xml inteiro
                t_lsProcessChain.append(t_oProcessXML.toString())

                workingDir = t_oGcDiagram.getDirName()
                t_Sm = s2iSessionManager.s2iSessionManager(workingDir)

                ## pegando o novo ID (criado pela s2iSessionManager) e passando para o s2idiagram
                t_oGcDiagram.SetSessionManager(t_Sm)
                t_oGcDiagram.SetIDBackendSession(t_Sm.m_sSessionId)

                #step sempre sera uma lista.. primeiro elemento eh uma mensagem, segundo eh o erro.. caso exista erro.. passar para o s2idiagram tb!
                t_oGcDiagram.SetErrorLog('')
                t_bEverythingOk = True
                t_Sm.NewInstance(self.batchModeOn, t_lsProcessChain)

        #falta pegar o retorno!!!!!!
        self.UpdateStatus(7)
    def on_ProcessToolBar_clickedIneer(self):
        page = self.widgets['WorkArea'].get_current_page()
        if self.diagrams.has_key(page):
            self.UpdateStatus(0)

            diagram = self.diagrams[page]

            process_XML = XMLParser("<harpia>" + \
                                           str(DiagramControl(diagram).get_process_chain()) + \
                                           "</harpia>", fromString=True)

            graph_size = len(list(process_XML.getTag("harpia").getTag("properties").getTagChildren()))

            if graph_size > 1:
                blocks = process_XML.getTag("harpia").getTag("properties").getChildTags("block")
                for t_oBlockProperties in blocks:
                    block_properties = t_oBlockProperties.getChildTags("property")
                    if int(t_oBlockProperties.type) == 00:  # 00 = acquisition block
                        inputType = 'file'
                        for block_property in block_properties:
                            if block_property.name == 'type':
                                print block_property.name
                                inputType = block_property.value

                            # adoção do paradigma monolítico.. nada de ficar mandando imagens por sockets!!
                            if block_property.name == 'filename' and inputType == 'file':
                                block_property.value = os.path.expanduser(block_property.value)
                                block_property.value = os.path.realpath(block_property.value)
                                if (not os.path.exists(block_property.value)):
                                    errMsg = _("Bad Filename: ") + block_property.value
                                    print(errMsg)
                                    self.SetStatusMessage(errMsg, 0)
                                    return

                    if int(t_oBlockProperties.type) == 01:  # 01 => save image
                        for block_property in block_properties:
                            if block_property.name == 'filename':
                                block_property.value = os.path.realpath(block_property.value)


                    # seguindo o paradigma de não mandar mais nada.. vamos testar com o haar =]
                    # não vamos mandar mais nada mas vamos traduzir o path do haarCascade pra algo real
                    if int(t_oBlockProperties.type) == 610:  # 610 => haar detector... passando a cascade .xml
                        for block_property in block_properties:
                            if block_property.name == 'cascade_name':
                                block_property.value = os.path.realpath(block_property.value)
                                if (not os.path.exists(block_property.value)):
                                    errMsg = _("Bad Filename: ") + block_property.value
                                    print(errMsg)
                                    self.SetStatusMessage(errMsg, 0)
                                    return

                # cpscotti standalone!!!
                process_chain = []  # lista pra n precisar ficar copiando prum lado e pro otro o xml inteiro
                process_chain.append(process_XML.getXML())

                session_manager = s2iSessionManager.s2iSessionManager()

                ## pegando o novo ID (criado pela s2iSessionManager) e passando para o s2idiagram
                self.diagrams[page].set_session_id(session_manager.session_id)

                # step sempre sera uma lista.. primeiro elemento eh uma mensagem, segundo eh o erro.. caso exista erro.. passar para o s2idiagram tb!
                self.diagrams[page].set_error_log('')
                t_bEverythingOk = True
                for step in session_manager.new_instance(process_chain):
                    if len(step) > 1:
                        if step[1] != '' and step[1] != None:
                            self.diagrams[page].append_error_log(step[1])
                            t_bEverythingOk = False
                    self.SetStatusMessage(step[0], t_bEverythingOk)
                    # self.widgets['StatusLabel'].set_text()
                    # print t_bEverythingOk
                    print step[0]
                # yield step#util caso se resolva usar a interface "lenta" ou se descubra como atualizar rapidamente a GUI

        # falta pegar o retorno!!!!!!
        self.UpdateStatus(7)
Esempio n. 3
0
    def on_ProcessToolBar_clickedIneer(self):
        t_nPage = self.widgets['WorkArea'].get_current_page()
        t_bIsLive = False
        if self.m_oGcDiagrams.has_key(t_nPage):
            self.UpdateStatus(0)

            t_oGcDiagram = self.m_oGcDiagrams[t_nPage]
            #print "PROCESS CHAIN",t_oS2iDiagram.GetProcessChain()
            #t_oProcessXML = bt.bind_string("<harpia>" + \
            #                               str(t_oGcDiagram.GetProcessChain()) + \
            #                               "</harpia>")
            #print len(list(t_oProcessXML.harpia.properties.childNodes))


            t_oProcessXML = XMLParser("<harpia>" + \
                                           str(t_oGcDiagram.GetProcessChain()) + \
                                           "</harpia>", fromString=True)
            #print t_oProcessXML

            graph_size = len(list(t_oProcessXML.getTag("harpia").getTag("properties").getTagChildren()))

            if graph_size > 1:
                blocks = t_oProcessXML.getTag("harpia").getTag("properties").getChildTags("block")
                for t_oBlockProperties in blocks:
                    block_properties = t_oBlockProperties.getChildTags("property")
                    if int(t_oBlockProperties.type) == 00:  # 00 = acquisition block
                        inputType = 'file'
                        for t_oProperty in block_properties:
                            if t_oProperty.name == 'type':
                                print t_oProperty.name
                                inputType = t_oProperty.value

                            ###Just in case we need to know if we are dealing with a live feed or not this early
                            # if inputType == 'video' or inputType == 'live':
                            #	#if not t_bIsLive:
                            #		#t_bIsLive = True

                            # adoção do paradigma monolítico.. nada de ficar mandando imagens por sockets!!
                            if t_oProperty.name == 'filename' and inputType == 'file':
                                t_oProperty.value = os.path.expanduser(t_oProperty.value)
                                t_oProperty.value = os.path.realpath(t_oProperty.value)
                                if (not os.path.exists(t_oProperty.value)):
                                    errMsg = _("Bad Filename: ") + t_oProperty.value
                                    print(errMsg)
                                    self.SetStatusMessage(errMsg, 0)
                                    return

                    if int(t_oBlockProperties.type) == 01:  # 01 => save image
                        for t_oProperty in block_properties:
                            if t_oProperty.name == 'filename':
                                t_oProperty.value = os.path.realpath(t_oProperty.value)


                    # seguindo o paradigma de não mandar mais nada.. vamos testar com o haar =]
                    # não vamos mandar mais nada mas vamos traduzir o path do haarCascade pra algo real
                    if int(t_oBlockProperties.type) == 610:  # 610 => haar detector... passando a cascade .xml
                        for t_oProperty in block_properties:
                            if t_oProperty.name == 'cascade_name':
                                t_oProperty.value = os.path.realpath(t_oProperty.value)
                                if (not os.path.exists(t_oProperty.value)):
                                    errMsg = _("Bad Filename: ") + t_oProperty.value
                                    print(errMsg)
                                    self.SetStatusMessage(errMsg, 0)
                                    return

                # cpscotti standalone!!!
                t_lsProcessChain = []  # lista pra n precisar ficar copiando prum lado e pro otro o xml inteiro
                t_lsProcessChain.append(t_oProcessXML.getXML())

                t_Sm = s2iSessionManager.s2iSessionManager()

                ## pegando o novo ID (criado pela s2iSessionManager) e passando para o s2idiagram
                self.m_oGcDiagrams[t_nPage].SetIDBackendSession(t_Sm.m_sSessionId)

                # step sempre sera uma lista.. primeiro elemento eh uma mensagem, segundo eh o erro.. caso exista erro.. passar para o s2idiagram tb!
                self.m_oGcDiagrams[t_nPage].set_error_log('')
                t_bEverythingOk = True
                for step in t_Sm.NewInstance(t_lsProcessChain):
                    if len(step) > 1:
                        if step[1] != '' and step[1] != None:
                            self.m_oGcDiagrams[t_nPage].append_error_log(step[1])
                            t_bEverythingOk = False
                    self.SetStatusMessage(step[0], t_bEverythingOk)
                    # self.widgets['StatusLabel'].set_text()
                    # print t_bEverythingOk
                    print step[0]
                # yield step#util caso se resolva usar a interface "lenta" ou se descubra como atualizar rapidamente a GUI

        # falta pegar o retorno!!!!!!
        self.UpdateStatus(7)
Esempio n. 4
0
    def on_ProcessToolBar_clickedIneer(self):
        page = self.widgets['WorkArea'].get_current_page()
        if self.diagrams.has_key(page):
            self.UpdateStatus(0)

            diagram = self.diagrams[page]

            process_XML = XMLParser("<harpia>" + \
                                           str(DiagramControl(diagram).get_process_chain()) + \
                                           "</harpia>", fromString=True)

            graph_size = len(list(process_XML.getTag("harpia").getTag("properties").getTagChildren()))

            if graph_size > 1:
                blocks = process_XML.getTag("harpia").getTag("properties").getChildTags("block")
                for t_oBlockProperties in blocks:
                    block_properties = t_oBlockProperties.getChildTags("property")
                    if int(t_oBlockProperties.type) == 00:  # 00 = acquisition block
                        inputType = 'file'
                        for block_property in block_properties:
                            if block_property.name == 'type':
                                print block_property.name
                                inputType = block_property.value

                            # adoção do paradigma monolítico.. nada de ficar mandando imagens por sockets!!
                            if block_property.name == 'filename' and inputType == 'file':
                                block_property.value = os.path.expanduser(block_property.value)
                                block_property.value = os.path.realpath(block_property.value)
                                if (not os.path.exists(block_property.value)):
                                    errMsg = _("Bad Filename: ") + block_property.value
                                    print(errMsg)
                                    self.__set_status_message(errMsg, 0)
                                    return

                    if int(t_oBlockProperties.type) == 01:  # 01 => save image
                        for block_property in block_properties:
                            if block_property.name == 'filename':
                                block_property.value = os.path.realpath(block_property.value)


                    # seguindo o paradigma de não mandar mais nada.. vamos testar com o haar =]
                    # não vamos mandar mais nada mas vamos traduzir o path do haarCascade pra algo real
                    if int(t_oBlockProperties.type) == 610:  # 610 => haar detector... passando a cascade .xml
                        for block_property in block_properties:
                            if block_property.name == 'cascade_name':
                                block_property.value = os.path.realpath(block_property.value)
                                if (not os.path.exists(block_property.value)):
                                    errMsg = _("Bad Filename: ") + block_property.value
                                    print(errMsg)
                                    self.__set_status_message(errMsg, 0)
                                    return

                # cpscotti standalone!!!
                process_chain = []  # lista pra n precisar ficar copiando prum lado e pro otro o xml inteiro
                process_chain.append(process_XML.getXML())

                session_manager = s2iSessionManager.s2iSessionManager()

                ## pegando o novo ID (criado pela s2iSessionManager) e passando para o s2idiagram
                self.diagrams[page].set_session_id(session_manager.session_id)

                # step sempre sera uma lista.. primeiro elemento eh uma mensagem, segundo eh o erro.. caso exista erro.. passar para o s2idiagram tb!
                self.diagrams[page].set_error_log('')
                t_bEverythingOk = True
                for step in session_manager.new_instance(process_chain):
                    if len(step) > 1:
                        if step[1] != '' and step[1] != None:
                            self.diagrams[page].append_error_log(step[1])
                            t_bEverythingOk = False
                    self.__set_status_message(step[0], t_bEverythingOk)
                    # self.widgets['StatusLabel'].set_text()
                    # print t_bEverythingOk
                    print step[0]
                # yield step#util caso se resolva usar a interface "lenta" ou se descubra como atualizar rapidamente a GUI

        # falta pegar o retorno!!!!!!
        self.UpdateStatus(7)