def markAsFinish(self, question): res = session.search3_f_a_f(sc_keys.questions.active, sc.SC_ARC, question) if res is not None: session.erase_el(res[0][1]) if len(res) is 1: session.gen3_f_a_f(segment, sc_keys.questions.finished, question, sc.SC_A_CONST | sc.SC_POS)
def run(self): while self.running: try: question = self.queue.get(self.wait_task, 0.1) nodes = session.search5_f_a_a_a_f(sc_keys.questions.initiated, sc.SC_A_CONST | sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST | sc.SC_POS, question) if nodes is not None: question = nodes[0][2] else: continue #print "[worker] get %s" % session.get_idtf(question) self.markAsActive(question) # search needed operation for oper, checkers in self.modules: # check question check = True for checker in checkers: #print checker if not checker.checking(question): check = False if check: oper = oper() result = oper.running(question) if result is not None: if len(result) != 0: self.makeAnswer(question, result) session.gen3_f_a_f(segment, sc_keys.questions.finished, question, sc.SC_A_CONST | sc.SC_POS) break self.markAsFinish(question) except Queue.Empty: time.sleep(0.1) if not self.wait_task: self.running = False except: self.markAsFinish(question) bug_report()
def run(self): while self.running: try: question = self.queue.get(self.wait_task, 0.1) nodes = session.search5_f_a_a_a_f(sc_keys.questions.initiated, sc.SC_A_CONST | sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST | sc.SC_POS, question) if nodes is not None: question = nodes[0][2] else: continue #print "[worker] get %s" % session.get_idtf(question) self.markAsActive(question) # search needed operation for oper, checkers in self.modules: # check question check = True for checker in checkers: #print checker if not checker.checking(question): check = False if check: oper = oper() result = oper.running(question) if result is not None: if len(result) != 0: self.makeAnswer(question, result) session.gen3_f_a_f(segment, sc_keys.questions.finished, question, sc.SC_A_CONST|sc.SC_POS) break self.markAsFinish(question) except Queue.Empty: time.sleep(0.1) if not self.wait_task: self.running = False except: self.markAsFinish(question) bug_report()
def makeAnswer(self, question, answer): if len(answer) is 0: return print "[Questions] Build answer" # создаем множество для ответа # создаем связку отношения между ответом и множеством ответа els = session.gen11_f_a_a_a_a_a_f_a_f_a_f(segment, question, sc.SC_A_CONST|sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST|sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST|sc.SC_POS, sc_keys.n_1, sc.SC_A_CONST|sc.SC_POS, sc_keys.n_2, sc.SC_A_CONST|sc.SC_POS, sc_keys.info.stype_sheaf) el = els[4] sheaf_node = els[2] # добавляем узлы ответа в множество answer = cantorSet(answer) for item in answer: session.gen3_f_a_f(segment, el, item, sc.SC_A_CONST | sc.SC_POS) # задаем отношение как "ответ*" session.gen3_f_a_f(segment, sc_keys.questions.nrel_answer, sheaf_node, sc.SC_A_CONST | sc.SC_POS) session.gen3_f_a_f(segment, sc_keys.questions.succesful, question, sc.SC_A_CONST | sc.SC_POS)
def makeAnswer(self, question, answer): if len(answer) is 0: return print "[Questions] Build answer" # создаем множество для ответа # создаем связку отношения между ответом и множеством ответа els = session.gen11_f_a_a_a_a_a_f_a_f_a_f( segment, question, sc.SC_A_CONST | sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST | sc.SC_POS, sc.SC_N_CONST, sc.SC_A_CONST | sc.SC_POS, sc_keys.n_1, sc.SC_A_CONST | sc.SC_POS, sc_keys.n_2, sc.SC_A_CONST | sc.SC_POS, sc_keys.info.stype_sheaf) el = els[4] sheaf_node = els[2] # добавляем узлы ответа в множество answer = cantorSet(answer) for item in answer: session.gen3_f_a_f(segment, el, item, sc.SC_A_CONST | sc.SC_POS) # задаем отношение как "ответ*" session.gen3_f_a_f(segment, sc_keys.questions.nrel_answer, sheaf_node, sc.SC_A_CONST | sc.SC_POS) session.gen3_f_a_f(segment, sc_keys.questions.succesful, question, sc.SC_A_CONST | sc.SC_POS)
def markAsActive(self, question): session.gen3_f_a_f(segment, sc_keys.questions.active, question, sc.SC_A_CONST | sc.SC_POS)