def test(actor_agent): actor_agent.env = Environment() start_time = time.time() done = 0 flow_number = 0 per_flow_cnt_total = 0 per_flow_cnt_valid = 0 time_record = {} manual = True try_model_id = 0 models = ["../models/A380_Model/A" + str(model_count) + "/policy/" for model_count in range(34)] while True: while done == 0: per_flow_cnt_total += 1 per_flow_cnt_valid += 1 policy_inputs, time_inputs, edge, time_slot, edge_selected_mask, cycle, LD_score, flag = actor_agent.invoke_model(manual) reward, done, reason = actor_agent.env.step(edge, time_slot, LD_score) # print(edge.id, time_slot, actor_agent.env.time, actor_agent.env.tt_flow_deadline) cur_time = time.time() if done == -1: if try_model_id < len(models): actor_agent.env.roll_back(1) # print(actor_agent.env.edge_usage()) # print(models[len(models) - 1 - try_model_id]) actor_agent.saver_policy.restore(actor_agent.sess, models[len(models) - 1 - try_model_id]) try_model_id += 1 actor_agent.env.enforce_next_query() done = 0 else: break elif done == 1: # 继续调度下一条流 delay = actor_agent.env.tt_flow_time_record[-1] - actor_agent.env.tt_flow_time_record[0] usage = actor_agent.env.edge_usage() print("TT_flow", flow_number, "cycle", cycle, "usage", usage, "use time", cur_time - start_time, "delay", delay, "reward", reward) time_record[flow_number] = [flow_number, cycle, per_flow_cnt_total, per_flow_cnt_valid, cur_time - start_time, delay] actor_agent.env.enforce_next_query() # 调度下一条流 start_time = time.time() flow_number += 1 per_flow_cnt_total = 0 per_flow_cnt_valid = 0 done = 0 if try_model_id != 0: try_model_id = 0 actor_agent.saver_policy.restore(actor_agent.sess, actor_agent.main_model) if actor_agent.env.tt_query_id == 59999: # actor_agent.env.schedule.show() break edge_usage = actor_agent.env.edge_usage() verify = Verify(actor_agent.env.schedule.sche) return actor_agent.env.tt_query_id, edge_usage, verify.judge_conflict()
def Request_Url(url,password): req=requests.get(url) Verify_code=Verify(req) #标志符号 headers={} data={Verify_code=Verify_code} s=requests.post(url,data=data,headers=headers) if "验证码错误" in s.text: Request_Url(url,password) if "" not in s.text: with open("success.txt","a+") as f1: f1.write(password) f1.write("\n") f1.close()
def setUp(self): '''Before each test, set up a blank database''' self.db_fd, Verify.app.config['DATABASE'] = tempfile.mkstemp() Verify.app.config['TESTING'] = True self.app = Verify.app.test_client() Verify.init_db()
import init import Signing import Verify init.init() Signing.signing() Verify.verify()
import SignIn import SignOut import Display import Verify userId= input('Enter your Email_Id') passCode= input('Enter your passCode') imapHost= 'imap.gmail.com' #for gmail connect= SignIn.Login(imapHost, userId, passCode) search= input('Enter the Inquiring Email id') if Verify.verifier(search)=='OK': Display.findMails('FROM', search, connect) else: print('U Entered a wrong Email Id/Address') search = input('Enter the Inquiring Email id again carefully and attentively') if Verify.verifier(search) == 'OK': Display.findMails('FROM', search, connect) else: print('Unsuccessfull Attempts Try Later!!') SignOut.LogOut() SignOut.LogOut(connect)
async def on_message(mes:discord.message.Message): if mes.content.strip().lower() == DEB+"help": await cmd.sayhelp(mes.channel) await cmd.sayThatChanel(mes, f"ทีหลังพิมพ์คำสั่งควรมีวงเล็บด้วยนะ @author") return thisCmd = cmd.parseCommand(mes.content) # Check first if mes.author.id == client.user.id: return if thisCmd == False: return # Check admin isAdmin = False if hasattr(mes.author, 'roles'): for r in mes.author.roles: if str(r) == "Admin OTOG": isAdmin = True isAdminChan = False if hasattr(mes.channel, 'changed_roles'): for r in mes.channel.changed_roles: if str(r) == "Admin OTOG": isAdminChan = True isAdmin = isAdmin and isAdminChan # List command goes here if thisCmd["command"] == (DEB + "test"): await cmd.test(client) if thisCmd["command"] == (DEB + "help"): await cmd.sayhelp(mes.channel, isAdmin) if thisCmd["command"] == (DEB + "change_log"): await cmd.sayCLog(mes.channel) if thisCmd["command"] == (DEB + "tasks") or thisCmd["command"] == (DEB + "problems"): await cmd.sayNProblems(mes) if thisCmd["command"] == (DEB + "ranking"): await cmd.sayRanking(mes) if thisCmd["command"] == (DEB + "contest"): await cmd.sayContestInfo(mes) #? play music if thisCmd["command"] == (DEB + "otogradio") or thisCmd["command"] == (DEB + "mPlay"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "ไม่ใส่ชื่อเพลง ก็ไม่เปิดให้!!!") else: #? Music Goes here if mes.author.voice != None: voice_channel = mes.author.voice.channel await cmd.sayThatChanel(mes, "กำลังหาเพลง...") #res = await vcMan.addSong(mes.guild.id, voice_channel, thisCmd["args"][0]) # if res == None: # await cmd.sayThatChanel(mes, ":x:หาเพลงไม่เจอง่ะ") # return await cmd.sayThatChanel(mes, f"||Bruh||") else: await cmd.sayThatChanel(mes, "หาแนลไม่เจอ ไม่เปิด!!!") if thisCmd["command"] == (DEB + "hello"): thisHello = ENUM.HELLO_TEXT[random.randint( 0, len(ENUM.HELLO_TEXT) - 1)] await cmd.sayThatChanel(mes, f"{thisHello} @author") if thisCmd["command"] == (DEB + "baka"): await cmd.sayThatChanel(mes, "<:baka:704310333120053248>") if thisCmd["command"] == (DEB + "guess_num"): idPer = mes.author.id if GNG.remain(idPer) == -1: await cmd.sayThatChanel(mes, ":crossed_swords:โห๋ 1-1 ได้ครับเจ้า @author:crossed_swords:") await cmd.gngHowto(mes.channel) GNG.initPer(idPer) dataBASS.saveFile() else: await cmd.sayThatChanel(mes, "เห้ย อย่าเล่นซ้ำเซ่!!!!??\nเวลาจะทายให้พิมพ์ `guess(ตัวเลข)` เอา!!! @author") if thisCmd["command"] == (DEB + "guess"): idPer = mes.author.id if GNG.remain(idPer) == -1: await cmd.sayThatChanel(mes, "ฮั่นแน่ อยากเล่นด้วยละสิ @author\nเวลาจะเล่นให้ใช้คำสั่ง `guess_num()` ก่อนเด้ออ") elif len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "จะทายความว่างเปล่าหรอ... ไม่น่าใช่น้าาาา") elif thisCmd["args"][0].strip() == "*": await mes.delete() await cmd.sayThatChanel(mes, ENUM.GNG_GIVE) GNG.removeGNG(idPer) elif not isInt(thisCmd["args"][0].strip()): await cmd.sayThatChanel(mes, f"ไม่น่าใช่ตัวเลขจำนวนเต็มน้าาาา") else: gus = int(thisCmd["args"][0].strip()) if gus <= 0 or gus > 100: await cmd.sayThatChanel(mes, "1 ถึง 100...\n๑ ถึง ๑๐๐...\n***หนึ่งถึงร้อยยยยย!!!!***") else: await mes.delete() result = GNG.guess(idPer, gus) await cmd.sayThatChanel(mes, result) if thisCmd["command"] == (DEB + "question"): idPer = mes.author.id if len(thisCmd["args"]) < 1: await mes.author.send("เมื่อเจ้าถามอะไรอ่ะ??? เจ้าลืมใส่ชื่อโจทย์...") elif thisCmd["value"] == "": if questionManager.isAlreadyAsk(idPer, thisCmd["args"][0]): ids = questionManager.removeQuestion(idPer, thisCmd["args"][0]) for idd in ids: delMes = await uID2Message(client, idd) await delMes.delete() await questionManager.reloadMessage(client) await mes.author.send(f":x:ลบคำถาม `{thisCmd['args'][0]}` เรียบร้อยแล้ว...") else: await mes.author.send("เมื่อเจ้าถามอะไรอ่ะ??? เจ้าถามความว่างเปล่ารี?") else: if questionManager.isAlreadyAsk(idPer, thisCmd["args"]): await mes.author.send(f":arrows_counterclockwise: เปลี่ยนคำถาม `{thisCmd['args'][0]}` เรียบร้อยแล้ว...") idQ = questionManager.modifyQuestion( idPer, thisCmd["args"][0], thisCmd["value"]) await questionManager.reloadMessage(client, idQ) else: if questionManager.crtQuestion(idPer) >= 1: await mes.author.send("เจ้าหมดโค้วต้าการถามแล้ว... รอก่อนนะ") else: mesIds = [] mesIds.append(messageToUniqueID(await mes.author.send(ENUM.QUEST_USER % (thisCmd["args"][0], thisCmd["value"], "รอไปก่อนแบบใจเย็นๆ...")))) mesIds.append(messageToUniqueID(await client.get_channel(ENUM.QUE_CHANNEL).send(ENUM.QUEST_ADMIN % (questionManager.lenAllQuest()+1, thisCmd["args"][0], thisCmd["value"])))) questionManager.newQuestion( idPer, thisCmd["args"][0], thisCmd["value"], mesIds) try: await mes.delete() except: print("Can't delete message...") if isAdmin: if thisCmd["command"] == (DEB + "version"): await cmd.sayThatChanel(mes, f"{ENUM.VER} เด้อออ") if thisCmd["command"] == (DEB + "ann"): if thisCmd["value"].strip() == "": await cmd.sayThatChanel(mes, "ประกาศความว่างเปล่า?") else: await cmd.sayAnn(mes, client, thisCmd["value"].strip()) if thisCmd["command"] == (DEB + "say"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "ประกาศในห้องไหนอ่ะะะ") elif thisCmd["value"].strip() == "": await cmd.sayThatChanel(mes, "ประกาศความว่างเปล่า?") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "Channel_ID ควรเป็น int นะะ") else: await cmd.sayAnother(mes, client, thisCmd["value"].strip(), int(thisCmd["args"][0])) if thisCmd["command"] == (DEB + "read"): if thisCmd["value"].strip() == "": await cmd.sayThatChanel(mes, "ให้อ่านความว่างเปล่า") else: print(f"=======Read form {mes.author.display_name}=======") print(thisCmd["value"].strip()) await cmd.sayThatChanel(mes, "อ่านสำเร็จ!!") if thisCmd["command"] == (DEB + "shutdown"): await cmd.sayThatChanel(mes, "ลาก่อย") await client.close() exit(0) if thisCmd["command"] == (DEB + "score_board"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "CONTEST ไหนนน") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "ID ควรเป็น int นะะ") else: await cmd.sayContestRanking(int(thisCmd["args"][0]), mes.channel) if thisCmd["command"] == (DEB + "send_score_board"): if len(thisCmd["args"]) < 2: await cmd.sayThatChanel(mes, "ดู Argument ดีๆ") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "ID ควรเป็น int นะะ") elif not isInt(thisCmd["args"][1]): await cmd.sayThatChanel(mes, "channel_id ควรเป็น int นะะ") else: await cmd.sayContestRanking(int(thisCmd["args"][0]), client.get_channel(int(thisCmd["args"][1]))) if thisCmd["command"] == (DEB + "test_verify"): code = thisCmd["value"].strip() if code == "": await cmd.sayThatChanel(mes, "ส่งความว่างเปล่ามาตรวจ?? เยี่ยมไปเล้ยยย") else: await cmd.sayThatChanel(mes, "ตรวจแป๊ป") await cmd.sayThatChanel(mes, Verify.doJudge(code)[0]) if thisCmd["command"] == (DEB + "force_reload"): ContestManager.reloading() await cmd.sayThatChanel(mes, "จัดให้ห้ห้ห้ห้!!") if thisCmd["command"] == (DEB + "check_verify"): verifyData = Verify.getDistinctData() if len(verifyData) == 0: await cmd.sayThatChanel(mes, "เย่... ยังไม่มีใครมา Verify เลย\n*เ ห ง า จุ ง*") else: strr = f"ตอนนี้มี `{len(verifyData)}` คนที่กำลังอยู่ในระหว่างการดำเนินการ Verify...\n" for someData in verifyData: ids = someData[0] namae = await cmd.getNameFromId(client, mes, int(ids)) strr += f"-{namae}({ids}) เหลืออีก {5 - someData[1]} ครั้ง\n" strr += f"\nรายงาน ณ {getNowTimeInThai()}" await cmd.sayThatChanel(mes, strr) if thisCmd["command"] == (DEB + "watch_code_verify"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "ค ว า ม ว่ า ง เ ป ล่ า") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "ID ควรเป็นจำนวนเต็มนะะนะนะนะนะนะ") elif Verify.getLenCodes(int(thisCmd["args"][0])) == 0: await cmd.sayThatChanel(mes, "ไม่มีข้อมูลการ Verify ของ ID นี้นะ") else: idPer = int(thisCmd['args'][0]) namae = await cmd.getNameFromId(client, mes, idPer) strr = f"======ข้อมูล Verify ของ {namae}======\n\n" for i in range(len(dataBASS.verify[str(idPer)])): strr += f"การส่งครั้งที่ {i+1}...\n```cpp\n{dataBASS.verify[str(idPer)][i]}\n```\n\n" strr += f"\nรายงาน ณ {getNowTimeInThai()}" await cmd.sayThatChanel(mes, strr) if thisCmd["command"] == (DEB + "q_remove"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "ล บ ค ว า ม ว่ า ง เ ป ล่ า") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "ID ควรเป็นจำนวนเต็มนะะนะนะนะนะนะ") else: idQ = int(thisCmd["args"][0]) if idQ > questionManager.lenAllQuest() or idQ <= 0: await cmd.sayThatChanel(mes, f"หา id {idQ} ไม่เจออ่ะะะ") else: strRes = f":x:ลบคำถาม `{dataBASS.questions[idQ-1][1]}` ที่ถามว่า `{dataBASS.questions[idQ-1][2]}` เรียบร้อยแล้ว...\nสำเร็จโดย {mes.author.name}" idms = questionManager.removeQuestionInd(idQ-1) for idd in idms: delMes = await uID2Message(client, idd) await delMes.delete() await questionManager.reloadMessage(client) await client.get_channel(ENUM.QUE_HIS_CHANNEL).send(strRes) await mes.delete() if thisCmd["command"] == (DEB + "q_clear"): strRes = f":fireworks:ระเบิดทุกๆคำถามเรียบร้อยแล้ว <:knowthatfeel:704310526200512622>\nสำเร็จโดย {mes.author.name}" for i in range(questionManager.lenAllQuest()-1, -1, -1): idms = questionManager.removeQuestionInd(i) for idd in idms: delMes = await uID2Message(client, idd) await delMes.delete() await client.get_channel(ENUM.QUE_HIS_CHANNEL).send(strRes) await mes.delete() if thisCmd["command"] == (DEB + "q_answer"): if len(thisCmd["args"]) < 1: await cmd.sayThatChanel(mes, "ตอบข้อไหนอ่ะ??") elif not isInt(thisCmd["args"][0]): await cmd.sayThatChanel(mes, "ID ควรเป็นจำนวนเต็มนะะนะนะนะนะนะ") elif thisCmd["value"] == "": await cmd.sayThatChanel(mes, "ตอบความว่างเปล่า??\nถ้าจะลบคำถามให้ใช้ `q_remove(<id>)` นะๆ") else: idQ = int(thisCmd["args"][0]) - 1 if idQ >= questionManager.lenAllQuest() or idQ < 0: await cmd.sayThatChanel(mes, f"หา id {idQ} ไม่เจออ่ะะะ") else: bigQuestId = dataBASS.questions[idQ][1] bigQuest = dataBASS.questions[idQ][2] bigQuestAnswer = thisCmd["value"] strRes = f":white_check_mark:ตอบคำถามสำเร็จโดย {mes.author.name}\nในข้อ `{bigQuestId}`\n:regional_indicator_q: : `{bigQuest}`\n:regional_indicator_a: : `{bigQuestAnswer}`" idms = questionManager.removeQuestionInd(idQ) userMess = await uID2Message(client, idms[0]) await userMess.channel.send(ENUM.QUEST_USER % (bigQuestId, bigQuest, bigQuestAnswer)) await userMess.delete() admiMess = await uID2Message(client, idms[1]) await admiMess.delete() await questionManager.reloadMessage(client) await client.get_channel(ENUM.QUE_HIS_CHANNEL).send(strRes) await mes.delete() # PART Verify if thisCmd["command"] == (DEB + "verify"): correctedRole = False if hasattr(mes.author, 'roles'): for r in mes.author.roles: correctedRole = correctedRole or (str(r) == "return 0;") else: return if not correctedRole: await mes.delete() return code = thisCmd["value"].strip() idPer = mes.author.id if code == "": await mes.author.send("ฮัลโล่ว เอ็งส่งโค้ดว่างเปล่ามาอ่ะ ตรวจไม่ได้เว้ยยย") await mes.delete() return if Verify.getLenCodes(idPer) == 5: await mes.author.send(ENUM.VERIF_NOPE) await mes.delete() return Verify.addCode(idPer, code) result = Verify.doJudge(code) if result[1]: # pass newRole = discord.utils.get(mes.guild.roles, name="OTOGer") await mes.author.send(f"```cpp\n{code}```\n") await mes.author.send(result[0]) await mes.author.edit(roles=[newRole]) await mes.delete() Verify.removeId(idPer) else: await mes.author.send(f"```cpp\n{code}```\n") await mes.author.send(result[0]) remain = 5 - Verify.getLenCodes(idPer) if remain == 0: await mes.author.send(ENUM.VERIF_END) else: await mes.author.send(ENUM.VERIF_REMAIN % (remain)) await mes.delete()