def _parse(self): """Parse menu item from sc-memory @author: Denis Koronchik """ if len(self.childs) > 0: return # do nothing current_translation = core.Kernel.getSingleton().getCurrentTranslation() # get child elements session = core.Kernel.session() #decomp = sc_utils.searchOneShotBinPairAttrFromNode(session, self._getScAddr(), keynodes.common.nrel_decomposition, sc.SC_CONST) decomp = sc_utils.searchOneShotBinPairAttrToNode(session, self._getScAddr(), keynodes.common.nrel_decomposition, sc.SC_CONST) # parse child items if decomp is not None: it = session.create_iterator(session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, decomp, sc.SC_A_CONST | sc.SC_POS,# | sc.SC_PERMANENT, sc.SC_N_CONST), True) while not it.is_over(): item_addr = it.value(2) item = SCgMenuItem(None, it.value(2), self) item.setPosition(self.position) self.childs.append(item) it.next()
def findPlanetProperty(session, planet, property, unit_attr): """ @param session: current workable session @type session: sc_session @param planet: planet which property we are finding @type planet: sc_global_addr @param property: property keynode @type property: sc_global_addr @param unit_attr: property unit attribute keynode @type unit_attr: sc_global_addr @return: property value of the planet @rtype: str """ identficationKey = keynodes.common.nrel_identification dec_system = space_keynodes.DefaultAttr.dec_system addr1 = sc_utils.searchOneShotBinPairAttrFromNode(session, planet, property, sc.SC_N_CONST) if addr1 is not None: addr2 = searchOneShotPosArcAttrFrom(session, addr1, unit_attr) addr3 = sc_utils.searchOneShotBinPairAttrToNode( session, addr2, identficationKey, sc.SC_N_CONST) addr4 = searchPosArcAttrFrom(session, addr3, dec_system) for addr in addr4: content = session.get_content_str(addr) if content is not None: return sc_utils.cp1251ToUtf8(str(content)) return None
def findPlanetTitle(session, planet, language): """ @param session: current workable session @type session: sc_session @param planet: planet which title we are finding @type planet: sc_global_addr @param language: language of title @type language: sc_global_addr @return: title of the planet @rtype: string """ identficationKey = keynodes.common.nrel_identification addr1 = sc_utils.searchOneShotBinPairAttrToNode(session, planet, identficationKey, sc.SC_N_CONST) if addr1 is not None: addr2 = searchPosArcFrom(session, addr1) for addr in addr2: is_spec_lang = sc_utils.checkIncToSets(session, addr, [language], sc.SC_A_CONST) if is_spec_lang is True: content = session.get_content_str(addr) if content is not None: return sc_utils.cp1251ToUtf8(content) return None
def findPlanetProperty(session, planet, property, unit_attr): """ @param session: current workable session @type session: sc_session @param planet: planet which property we are finding @type planet: sc_global_addr @param property: property keynode @type property: sc_global_addr @param unit_attr: property unit attribute keynode @type unit_attr: sc_global_addr @return: property value of the planet @rtype: str """ identficationKey = keynodes.common.nrel_identification dec_system = space_keynodes.DefaultAttr.dec_system addr1 = sc_utils.searchOneShotBinPairAttrFromNode(session, planet, property, sc.SC_N_CONST) if addr1 is not None: addr2 = searchOneShotPosArcAttrFrom(session, addr1, unit_attr) addr3 = sc_utils.searchOneShotBinPairAttrToNode(session, addr2, identficationKey, sc.SC_N_CONST) addr4 = searchPosArcAttrFrom(session, addr3, dec_system) for addr in addr4: content = session.get_content_str(addr) if content is not None: return sc_utils.cp1251ToUtf8(str(content)) return None
def getFormatIcon(self, _format): """Return icon associated with specified format @param _format: sc-node that designate format @type _format: sc_addr @return: Name of texture that contains icon associated to _format, if there are no any icons, then return None """ import suit.core.sc_utils as sc_utils import sc_core.constants as sc_constants import sc_core.pm as sc import ogre.renderer.OGRE as ogre session = core.Kernel.session() icon = None idtf_set = sc_utils.searchOneShotBinPairAttrToNode( session, _format, keynodes.common.nrel_identification, sc.SC_CONST ) if idtf_set is not None: it1 = session.create_iterator( session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, idtf_set, sc.SC_A_CONST, sc.SC_N_CONST), True ) while not it1.is_over(): if sc_utils.checkIncToSets(session, it1.value(2), [keynodes.common.group_image], sc.SC_CONST): icon = it1.value(2) break it1.next() if icon is None: return None _fmt = sc_utils.getContentFormat(session, icon) assert _fmt is not None _cont = session.get_content_const(icon) assert _cont is not None _cont_data = _cont.convertToCont() data = _cont.get_data(_cont_data.d.size) stream = ogre.MemoryDataStream("%s" % str(self), _cont_data.d.size, False) stream.setData(data) try: img = ogre.Image() img.load(stream, ogre.Image.getFileExtFromMagic(stream)) except: import sys, traceback print "Error:", sys.exc_info()[0] traceback.print_exc(file=sys.stdout) icon_name = "icon_%s" % str(_format) ogre.TextureManager.getSingleton().loadImage(icon_name, "General", img) return icon_name return None
def user_output_answer(_params, _segment): # trying to find question node session = core.Kernel.session() # getting answer sheaf node answer_sheaf = session.search_one_shot(session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, keynodes.questions.nrel_answer, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, _params), True, 5) if answer_sheaf is None: raise Exception("Can't find answer sheaf node") answer_sheaf = answer_sheaf[2] # go to begin of pair question_node = session.search_one_shot(session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, answer_sheaf, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, keynodes.n_1), True, 5) if question_node is None: raise Exception("Can't find question node") question_node = question_node[2] if question_node is None: return # get author and check if it's a user authors_set = sc_utils.searchOneShotBinPairAttrFromNode(session, question_node, keynodes.common.nrel_authors, sc_core.pm.SC_CONST) if authors_set is None: return is_user = False it = session.create_iterator(session.sc_constraint_new(sc_core.constants.CONSTR_3_f_a_a, authors_set, sc_core.pm.SC_A_CONST | sc_core.pm.SC_POS, sc_core.pm.SC_N_CONST), True) while not it.is_over(): author = it.value(2) if sc_utils.checkIncToSets(session, author, [keynodes.ui.user], sc_core.pm.SC_CONST): is_user = True it.next() if not is_user: return # get answer node answer_node = session.search_one_shot(session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, answer_sheaf, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, keynodes.n_2), True, 5) if answer_node is None: return answer_node = answer_node[2] # get output windows output_set = sc_utils.searchOneShotBinPairAttrToNode(session, question_node, keynodes.ui.nrel_set_of_output_windows, sc_core.pm.SC_CONST) if output_set is None: return it = session.create_iterator(session.sc_constraint_new(sc_core.constants.CONSTR_3_f_a_a, output_set, sc_core.pm.SC_A_CONST | sc_core.pm.SC_POS, sc_core.pm.SC_N_CONST), True) while not it.is_over(): try: core.Kernel.getSingleton().translateFromSc(answer_node, it.value(2)) except: import sys, traceback print "Error:", sys.exc_info()[0] traceback.print_exc(file=sys.stdout) it.next()
def getFormatIcon(self, _format): """Return icon associated with specified format @param _format: sc-node that designate format @type _format: sc_addr @return: Name of texture that contains icon associated to _format, if there are no any icons, then return None """ import suit.core.sc_utils as sc_utils import sc_core.constants as sc_constants import sc_core.pm as sc import ogre.renderer.OGRE as ogre session = core.Kernel.session() icon = None idtf_set = sc_utils.searchOneShotBinPairAttrToNode( session, _format, keynodes.common.nrel_identification, sc.SC_CONST) if idtf_set is not None: it1 = session.create_iterator( session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, idtf_set, sc.SC_A_CONST, sc.SC_N_CONST), True) while not it1.is_over(): if sc_utils.checkIncToSets(session, it1.value(2), [keynodes.common.group_image], sc.SC_CONST): icon = it1.value(2) break it1.next() if icon is None: return None _fmt = sc_utils.getContentFormat(session, icon) assert _fmt is not None _cont = session.get_content_const(icon) assert _cont is not None _cont_data = _cont.convertToCont() data = _cont.get_data(_cont_data.d.size) stream = ogre.MemoryDataStream("%s" % str(self), _cont_data.d.size, False) stream.setData(data) try: img = ogre.Image() img.load(stream, ogre.Image.getFileExtFromMagic(stream)) except: import sys, traceback print "Error:", sys.exc_info()[0] traceback.print_exc(file=sys.stdout) icon_name = "icon_%s" % str(_format) ogre.TextureManager.getSingleton().loadImage( icon_name, "General", img) return icon_name return None
def init_cmd(session, segment, sheet, _menu_item_addr, _general_formul, _cmd_class_set, _init_set): """Initialize question/command from template @param session: Session to work with sc-memory @param segment: Segment to create sc-constructions @param sheet: Current root sheet (command initiated from it) @param _menu_item_addr: sc-element that designate command (question) menu item @type _menu_item_addr: sc_addr @param _general_formul: sc-element that designate general formulation relation (different for questions and commands) @type _general_formul: sc_addr @param _cmd_class_set: sc-element that designate class of commands (used to search command node in template) @type _cmd_class_set: sc_addr @param _init_set: sc-element that designate initiated commands set (different for commands and questions) @type _init_set: sc_addr """ kernel = core.Kernel.getSingleton() # getting question template q_templ = sc_utils.searchOneShotBinPairAttrToNode(session, _menu_item_addr, _general_formul, sc.SC_CONST) if not q_templ: raise RuntimeWarning("Question '%s' haven't template" % _caption) return # getting question node it = session.create_iterator( session.sc_constraint_new(sc_constants.CONSTR_5_f_a_a_a_f, _cmd_class_set, sc.SC_ARC, sc.SC_NODE, sc.SC_ARC, q_templ), True) question_node = None while not it.is_over(): if sc_utils.checkIncToSets(session, it.value(2), [q_templ], 0): question_node = it.value(2) break it.next() if question_node is None: raise RuntimeError( "Can't get command (question) node for a '%s' command" % str(_menu_item_addr)) # creating question using template: # * iterate through elements of template set # * making values of parameters cmd_desc_..., add that values to addit_elements map # * replace var elements to const elements # * replace meta elements to var elements # * link replaced arcs params = {} addit_elements = { } # additional elements we need to add into question after params setup elements = [] pairs = [] it = session.create_iterator( session.sc_constraint_new( sc_constants.CONSTR_3_f_a_a, q_templ, sc.SC_A_CONST | sc.SC_POS, # | sc.SC_PERMANENT, 0), True) while not it.is_over(): _el = it.value(2) elements.append(_el) # selected elements if _el.this == keynodes.ui.arg_set.this: params[str(_el.this)], elms = get_arguments_set(session, segment) addit_elements[str(_el.this)] = elms elif _el.this == keynodes.ui.arg_set_only.this: # place just set node into question node params[str(_el.this)], elms = get_arguments_set(session, segment) elif _el.this == keynodes.ui.arg_cur_window.this: params[str(_el.this)] = sheet elif _el.this == keynodes.ui.arg_1.this: arguments = core.Kernel.getSingleton().getArguments() if len(arguments) > 0: params[str(_el.this)] = arguments[0]._getScAddr() elif _el.this == keynodes.ui.arg_2.this: arguments = core.Kernel.getSingleton().getArguments() if len(arguments) > 1: params[str(_el.this)] = arguments[1]._getScAddr() # elif _el.this == keynodes.ui.cmd_desc_curr_window.this: # params[str(_el.this)] = kernel.rootSheet._getScAddr() else: el_type = session.get_type(_el) idtf = session.get_idtf(_el) if not sc_utils.isSystemId(idtf) or (el_type & sc.SC_CONST): params[str(_el.this)] = _el else: # recreate var and meta elements using rules: # * var -> const # * meta -> var post_type = 0 if el_type & sc.SC_VAR: post_type = sc.SC_CONST elif el_type & sc.SC_META: post_type = sc.SC_VAR else: raise RuntimeWarning( "Unknown const type for element '%s'" % str(_el)) if el_type & sc.SC_ARC: pairs.append(_el) params[str(_el.this)] = session.create_el( segment, sc.SC_ARC | post_type) elif el_type & sc.SC_NODE: params[str(_el.this)] = session.create_el( segment, sc.SC_NODE | post_type) # TODO: copy structure types for elements it.next() # add selected set to question set q_node_new = params[str(question_node.this)] if sc_utils.checkIncToSets( session, keynodes.ui.arg_set, [question_node], sc.SC_POS | sc.SC_VAR) and sc_utils.checkIncToSets( session, keynodes.ui.arg_set, [q_templ], sc.SC_POS | sc.SC_CONST): # make pairs to additional elements for el in addit_elements[str(keynodes.ui.arg_set.this)]: assert sc_utils.createPairPosPerm(session, segment, q_node_new, el, sc.SC_CONST) # linking arcs for pair in pairs: # get begin and end elements _beg = session.get_beg(pair) _end = session.get_end(pair) if params.has_key(str(_beg.this)): _beg = params[str(_beg.this)] if params.has_key(str(_end.this)): _end = params[str(_end.this)] pair_new = params[str(pair.this)] session.set_beg(pair_new, _beg) session.set_end(pair_new, _end) # make authors set authors_node = sc_utils.createNodeElement(session, segment, sc.SC_CONST) sc_utils.createPairPosPerm(session, segment, authors_node, core.Kernel.getSingleton().getUserAddr(), sc.SC_CONST) assert authors_node is not None authors_pair_sheaf = sc_utils.createPairBinaryOrient( session, segment, params[str(question_node.this)], authors_node, sc.SC_CONST) assert authors_pair_sheaf is not None assert sc_utils.createPairPosPerm(session, segment, keynodes.common.nrel_authors, authors_pair_sheaf, sc.SC_CONST) # make output windows set output_node = sc_utils.createNodeElement(session, segment, sc.SC_CONST) assert output_node is not None # sc_utils.copySet(session, keynodes.ui.set_output_windows, output_node, segment) output_count = 0 it = session.create_iterator( session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, keynodes.ui.set_output_windows, sc.SC_ARC, 0), True) while not it.is_over(): sc_utils.createPair(session, segment, output_node, it.value(2), session.get_type(it.value(1))) output_count += 1 it.next() if output_count == 0: sc_utils.createPairPosPerm(session, segment, output_node, kernel.getMainWindow()._getScAddr(), sc.SC_CONST) # link output windows set to question output_sheaf = sc_utils.createPairBinaryOrient( session, segment, output_node, params[str(question_node.this)], sc.SC_CONST) assert output_sheaf is not None sc_utils.createPairPosPerm(session, segment, keynodes.ui.nrel_set_of_output_windows, output_sheaf, sc.SC_CONST) # initiate question assert sc_utils.createPairPosPerm(session, segment, _init_set, params[str(question_node.this)], sc.SC_CONST) is not None
def init_cmd(session, segment, sheet, _menu_item_addr, _general_formul, _cmd_class_set, _init_set): """Initialize question/command from template @param session: Session to work with sc-memory @param segment: Segment to create sc-constructions @param sheet: Current root sheet (command initiated from it) @param _menu_item_addr: sc-element that designate command (question) menu item @type _menu_item_addr: sc_addr @param _general_formul: sc-element that designate general formulation relation (different for questions and commands) @type _general_formul: sc_addr @param _cmd_class_set: sc-element that designate class of commands (used to search command node in template) @type _cmd_class_set: sc_addr @param _init_set: sc-element that designate initiated commands set (different for commands and questions) @type _init_set: sc_addr """ kernel = core.Kernel.getSingleton() # getting question template q_templ = sc_utils.searchOneShotBinPairAttrToNode(session, _menu_item_addr, _general_formul, sc.SC_CONST) if not q_templ: raise RuntimeWarning("Question '%s' haven't template" % _caption) return # getting question node it = session.create_iterator(session.sc_constraint_new(sc_constants.CONSTR_5_f_a_a_a_f, _cmd_class_set, sc.SC_ARC, sc.SC_NODE, sc.SC_ARC, q_templ), True) question_node = None while not it.is_over(): if sc_utils.checkIncToSets(session, it.value(2), [q_templ], 0): question_node = it.value(2) break it.next() if question_node is None: raise RuntimeError("Can't get command (question) node for a '%s' command" % str(_menu_item_addr)) # creating question using template: # * iterate through elements of template set # * making values of parameters cmd_desc_..., add that values to addit_elements map # * replace var elements to const elements # * replace meta elements to var elements # * link replaced arcs params = {} addit_elements = {} # additional elements we need to add into question after params setup elements = [] pairs = [] it = session.create_iterator(session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, q_templ, sc.SC_A_CONST | sc.SC_POS,# | sc.SC_PERMANENT, 0), True) while not it.is_over(): _el = it.value(2) elements.append(_el) # selected elements if _el.this == keynodes.ui.arg_set.this: params[str(_el.this)], elms = get_arguments_set(session, segment) addit_elements[str(_el.this)] = elms elif _el.this == keynodes.ui.arg_set_only.this: # place just set node into question node params[str(_el.this)], elms = get_arguments_set(session, segment) elif _el.this == keynodes.ui.arg_all_el.this: params[str(_el.this)], elms = get_all_elements_set(session, segment) elif _el.this == keynodes.ui.arg_cur_window.this: params[str(_el.this)] = sheet elif _el.this == keynodes.ui.arg_1.this: arguments = core.Kernel.getSingleton().getArguments() if len(arguments) > 0: params[str(_el.this)] = arguments[0]._getScAddr() elif _el.this == keynodes.ui.arg_2.this: arguments = core.Kernel.getSingleton().getArguments() if len(arguments) > 1: params[str(_el.this)] = arguments[1]._getScAddr() elif _el.this == keynodes.ui.arg_3.this: arguments = core.Kernel.getSingleton().getArguments() if len(arguments) > 1: params[str(_el.this)] = arguments[2]._getScAddr() # elif _el.this == keynodes.ui.cmd_desc_curr_window.this: # params[str(_el.this)] = kernel.rootSheet._getScAddr() else: el_type = session.get_type(_el) idtf = session.get_idtf(_el) if not sc_utils.isSystemId(idtf) or (el_type & sc.SC_CONST): params[str(_el.this)] = _el else: # recreate var and meta elements using rules: # * var -> const # * meta -> var post_type = 0 if el_type & sc.SC_VAR: post_type = sc.SC_CONST elif el_type & sc.SC_META: post_type = sc.SC_VAR else: raise RuntimeWarning("Unknown const type for element '%s'" % str(_el)) if el_type & sc.SC_ARC: pairs.append(_el) params[str(_el.this)] = session.create_el(segment, sc.SC_ARC | post_type) elif el_type & sc.SC_NODE: params[str(_el.this)] = session.create_el(segment, sc.SC_NODE | post_type) # TODO: copy structure types for elements it.next() # add selected set to question set q_node_new = params[str(question_node.this)] if sc_utils.checkIncToSets(session, keynodes.ui.arg_set, [question_node], sc.SC_POS | sc.SC_VAR) and sc_utils.checkIncToSets(session, keynodes.ui.arg_set, [q_templ], sc.SC_POS | sc.SC_CONST): # make pairs to additional elements for el in addit_elements[str(keynodes.ui.arg_set.this)]: assert sc_utils.createPairPosPerm(session, segment, q_node_new, el, sc.SC_CONST) # linking arcs for pair in pairs: # get begin and end elements _beg = session.get_beg(pair) _end = session.get_end(pair) if params.has_key(str(_beg.this)): _beg = params[str(_beg.this)] if params.has_key(str(_end.this)): _end = params[str(_end.this)] pair_new = params[str(pair.this)] session.set_beg(pair_new, _beg) session.set_end(pair_new, _end) # make authors set authors_node = sc_utils.createNodeElement(session, segment, sc.SC_CONST) sc_utils.createPairPosPerm(session, segment, authors_node, core.Kernel.getSingleton().getUserAddr(), sc.SC_CONST) assert authors_node is not None authors_pair_sheaf = sc_utils.createPairBinaryOrient(session, segment, params[str(question_node.this)], authors_node, sc.SC_CONST) assert authors_pair_sheaf is not None assert sc_utils.createPairPosPerm(session, segment, keynodes.common.nrel_authors, authors_pair_sheaf, sc.SC_CONST) # make output windows set output_node = sc_utils.createNodeElement(session, segment, sc.SC_CONST) assert output_node is not None # sc_utils.copySet(session, keynodes.ui.set_output_windows, output_node, segment) output_count = 0 it = session.create_iterator(session.sc_constraint_new(sc_constants.CONSTR_3_f_a_a, keynodes.ui.set_output_windows, sc.SC_ARC, 0), True) while not it.is_over(): sc_utils.createPair(session, segment, output_node, it.value(2), session.get_type(it.value(1))) output_count += 1 it.next() if output_count == 0: sc_utils.createPairPosPerm(session, segment, output_node, kernel.getMainWindow()._getScAddr(), sc.SC_CONST ) # link output windows set to question output_sheaf = sc_utils.createPairBinaryOrient(session, segment, output_node, params[str(question_node.this)], sc.SC_CONST) assert output_sheaf is not None sc_utils.createPairPosPerm(session, segment, keynodes.ui.nrel_set_of_output_windows, output_sheaf, sc.SC_CONST) # initiate question assert sc_utils.createPairPosPerm(session, segment, _init_set, params[str(question_node.this)], sc.SC_CONST) is not None
def user_output_answer(_params, _segment): # trying to find question node session = core.Kernel.session() # getting answer sheaf node answer_sheaf = session.search_one_shot( session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, keynodes.questions.nrel_answer, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, _params), True, 5) if answer_sheaf is None: raise Exception("Can't find answer sheaf node") answer_sheaf = answer_sheaf[2] # go to begin of pair question_node = session.search_one_shot( session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, answer_sheaf, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, keynodes.n_1), True, 5) if question_node is None: raise Exception("Can't find question node") question_node = question_node[2] if question_node is None: return # get author and check if it's a user authors_set = sc_utils.searchOneShotBinPairAttrFromNode( session, question_node, keynodes.common.nrel_authors, sc_core.pm.SC_CONST) if authors_set is None: return is_user = False it = session.create_iterator( session.sc_constraint_new(sc_core.constants.CONSTR_3_f_a_a, authors_set, sc_core.pm.SC_A_CONST | sc_core.pm.SC_POS, sc_core.pm.SC_N_CONST), True) while not it.is_over(): author = it.value(2) if sc_utils.checkIncToSets(session, author, [keynodes.ui.user], sc_core.pm.SC_CONST): is_user = True it.next() if not is_user: return # get answer node answer_node = session.search_one_shot( session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f, answer_sheaf, sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST, sc_core.pm.SC_A_CONST, keynodes.n_2), True, 5) if answer_node is None: return answer_node = answer_node[2] # get output windows output_set = sc_utils.searchOneShotBinPairAttrToNode( session, question_node, keynodes.ui.nrel_set_of_output_windows, sc_core.pm.SC_CONST) if output_set is None: return it = session.create_iterator( session.sc_constraint_new(sc_core.constants.CONSTR_3_f_a_a, output_set, sc_core.pm.SC_A_CONST | sc_core.pm.SC_POS, sc_core.pm.SC_N_CONST), True) while not it.is_over(): try: core.Kernel.getSingleton().translateFromSc(answer_node, it.value(2)) except: import sys, traceback print "Error:", sys.exc_info()[0] traceback.print_exc(file=sys.stdout) it.next()