Exemplo n.º 1
0
def build_group_tree_formdata(formdata):
    def group_process(f):
        for grp in sorted(formdata):
            yield formdata[grp].copy()
    return _build_groups_db(GroupTree, None, group_builder=group_process)
Exemplo n.º 2
0
def build_group_tree_db(db_groups):
    def group_process(f):
        for grp in db_groups:
            yield grp.__dict__.copy()
    return _build_groups_db(GroupTree, None, group_builder=group_process)
Exemplo n.º 3
0
def build_group_tree_formdata(formdata):
    def group_process(f):
        for grp in sorted(formdata):
            yield formdata[grp].copy()
    return _build_groups_db(GroupTree, None, group_builder=group_process)
Exemplo n.º 4
0
def build_group_tree_db(db_groups):
    def group_process(f):
        for grp in db_groups:
            yield grp.__dict__.copy()
    return _build_groups_db(GroupTree, None, group_builder=group_process)
    # Set intermediate nodes as sum of children
    for group in groups:
        if not group.is_leaf:
            group.busy = sum(x.busy for x in group.get_children())


def fill_busy_db(groups):
    con, cur = db.get()
    for g in groups:
        cur.execute('UPDATE groups SET busy = %d WHERE group_name = "%s"' %
                    (g.busy, g.full_name))
    cur.execute('UPDATE groups SET last_update = %s', datetime.datetime.now())
    con.commit()
    con.close()


if __name__ == '__main__':
    # Build group tree from groups that count the "busy" field in the db
    groups = _build_groups_db(BusyGroup, ('group_name',))

    # Fill tree with info from condor
    populate_group_busy(groups)

    # Update DB with info in group tree
    try:
        fill_busy_db(groups)
    except MySQLdb.Error as e:
        log.error("DB Error %d: %s", e.args[0], e.args[1])
        sys.exit(1)
Exemplo n.º 6
0
    # Set intermediate nodes as sum of children
    for group in groups:
        if not group.is_leaf:
            group.busy = sum(x.busy for x in group.get_children())


def fill_busy_db(groups):
    con, cur = db.get()
    for g in groups:
        cur.execute('UPDATE groups SET busy = %d WHERE group_name = "%s"' %
                    (g.busy, g.full_name))
    cur.execute('UPDATE groups SET last_update = %s', datetime.datetime.now())
    con.commit()
    con.close()


if __name__ == '__main__':
    # Build group tree from groups that count the "busy" field in the db
    groups = _build_groups_db(BusyGroup, ('group_name', ))

    # Fill tree with info from condor
    populate_group_busy(groups)

    # Update DB with info in group tree
    try:
        fill_busy_db(groups)
    except MySQLdb.Error as e:
        log.error("DB Error %d: %s", e.args[0], e.args[1])
        sys.exit(1)