def find_all_inactiveNode(): mydb.open() # active =1 means it is active result = mydb.query_db('select * from node WHERE active=0', one=False) mydb.close_db() nidList=[] if result: for nid in result: nidList.append(nid['nid']) return nidList
def randomly_inactive_node(seed): num=random.randint(0,100) if(num<seed): mydb.open() # active =1 means it is active result = mydb.query_db('select * from node WHERE active=1', one=False) mydb.close_db() nidList=[] if result: for nid in result: nidList.append(nid['nid']) inactive_nid=nidList[random.randint(0, len(nidList)-1)] # set not whose nid is inactive_nid to inactive status, pass nid and inactive(0) change_node_status(inactive_nid, 0) app.config['updated'] = True print find_all_inactiveNode()