def list_overrides(suite, component, otype, session): dat = {} s = get_suite(suite, session) if s is None: utils.fubar("Suite '%s' not recognised." % (suite)) dat['suiteid'] = s.suite_id c = get_component(component, session) if c is None: utils.fubar("Component '%s' not recognised." % (component)) dat['componentid'] = c.component_id o = get_override_type(otype) if o is None: utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype)) dat['typeid'] = o.overridetype_id if otype == "dsc": q = session.execute("""SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = :suiteid AND o.component = :componentid AND o.type = :typeid AND o.section = s.id ORDER BY s.section, o.package""", dat) for i in q.fetchall(): print(utils.result_join(i)) else: q = session.execute("""SELECT o.package, p.priority, s.section, o.maintainer, p.level FROM override o, priority p, section s WHERE o.suite = :suiteid AND o.component = :componentid AND o.type = :typeid AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package""", dat) for i in q.fetchall(): print(utils.result_join(i[:-1]))
def do_list(output_file, suite, component, otype, session): """ Fetch override data for suite from the database and dump it. @type output_file: fileobject @param output_file: where to write the overrides to @type suite: Suite object @param suite: A suite object describing the Suite @type component: Component object @param component: The name of the component @type otype: OverrideType object @param otype: object of type of override. deb/udeb/dsc @type session: SQLA Session @param session: the database session in use """ # Here's a nice example of why the object API isn't always the # right answer. On my laptop, the object version of the code # takes 1:45, the 'dumb' tuple-based one takes 0:16 - mhy if otype.overridetype == "dsc": # q = session.query(Override).filter_by(suite_id = suite.suite_id) # q = q.filter_by(component_id = component.component_id) # q = q.filter_by(overridetype_id = otype.overridetype_id) # q = q.join(Section).order_by(Section.section, Override.package) # for o in q.all(): # dat = (o.package, o.section.section, o.maintainer) # output_file.write(utils.result_join(dat) + '\n') q = session.execute( "SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite.suite_id, component.component_id, otype.overridetype_id) ) for i in q.fetchall(): output_file.write(utils.result_join(i) + "\n") else: # q = session.query(Override).filter_by(suite_id = suite.suite_id) # q = q.filter_by(component_id = component.component_id) # q = q.filter_by(overridetype_id = otype.overridetype_id) # q = q.join(Priority).join(Section).order_by(Section.section, Priority.level, Override.package) # for o in q.all(): # dat = (o.package, o.priority.priority, o.section.section, o.maintainer) # output_file.write(utils.result_join(dat) + '\n') q = session.execute( "SELECT o.package, p.priority, s.section, o.maintainer FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite.suite_id, component.component_id, otype.overridetype_id) ) for i in q.fetchall(): output_file.write(utils.result_join(i) + "\n")
def do_list(output_file, suite, component, otype, session): """ Fetch override data for suite from the database and dump it. @type output_file: fileobject @param output_file: where to write the overrides to @type suite: Suite object @param suite: A suite object describing the Suite @type component: Component object @param component: The name of the component @type otype: OverrideType object @param otype: object of type of override. deb/udeb/dsc @type session: SQLA Session @param session: the database session in use """ # Here's a nice example of why the object API isn't always the # right answer. On my laptop, the object version of the code # takes 1:45, the 'dumb' tuple-based one takes 0:16 - mhy if otype.overridetype == "dsc": #q = session.query(Override).filter_by(suite_id = suite.suite_id) #q = q.filter_by(component_id = component.component_id) #q = q.filter_by(overridetype_id = otype.overridetype_id) #q = q.join(Section).order_by(Section.section, Override.package) #for o in q.all(): # dat = (o.package, o.section.section, o.maintainer) # output_file.write(utils.result_join(dat) + '\n') q = session.execute( "SELECT o.package, s.section, o.maintainer FROM override o, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.section = s.id ORDER BY s.section, o.package" % (suite.suite_id, component.component_id, otype.overridetype_id)) for i in q.fetchall(): output_file.write(utils.result_join(i) + '\n') else: #q = session.query(Override).filter_by(suite_id = suite.suite_id) #q = q.filter_by(component_id = component.component_id) #q = q.filter_by(overridetype_id = otype.overridetype_id) #q = q.join(Priority).join(Section).order_by(Section.section, Priority.level, Override.package) #for o in q.all(): # dat = (o.package, o.priority.priority, o.section.section, o.maintainer) # output_file.write(utils.result_join(dat) + '\n') q = session.execute( "SELECT o.package, p.priority, s.section, o.maintainer FROM override o, priority p, section s WHERE o.suite = %s AND o.component = %s AND o.type = %s AND o.priority = p.id AND o.section = s.id ORDER BY s.section, p.level, o.package" % (suite.suite_id, component.component_id, otype.overridetype_id)) for i in q.fetchall(): output_file.write(utils.result_join(i) + '\n')