def __init__(self, runtimes, username=None, passwd=None, start_time=None): #conf self.conf = ljy_config.getconf().get_config() self.__version = self.conf["version"] self.host = self.conf["host"] self.runtimes = int(runtimes) #info self.start_time = start_time self.username = "" if username is not None: self.username = username self.passwd = passwd self.token = "" self.userId = "" #headers self.cookies = {} self.headers = { "Accept": "application/json, text/plain, */*", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", "Content-Type": "", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", "Origin": "%s" % (self.host) }
def start_test(): c = ljy_config.getconf() print("Step 1. ", c.get_config_path()) print("Step 2. ", c.get_config()["thread"]) print("Step 3. ", c.getuserlist()[0]) img_file = c.get_resource_path() img_file += "cyberpunk.png" if os.path.exists(img_file): print("Step 4. ", img_file) else: print("%s not found!" % (img_file))
def __init__(self,runtimes,username=None,passwd=None,start_time=None,studentIdList=None): #conf self.conf=ljy_config.getconf().get_config() self.host=self.conf["host"] self.runtimes=int(runtimes) #info self.start_time=start_time self.username="" if username is not None: self.username=username self.passwd=passwd self.token=self.conf["token"] self.userId="" #headers self.cookies={} self.headers={ "Accept":"application/json, text/plain, */*", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", "Content-Type":"application/json;charset=UTF-8", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9", "Access-Token":self.token, "Tenant-Id":self.conf["tenant-id"], "Origin": "%s"%(self.host) } self.publishId="" self.paperId=""#试卷ID self.examId=""#考试ID self.classId="" self.studentId_first=""#第一个手动上传作答图片的学生 self.studentIdlist=[] self.studentId=""#userid self.examNumber=0#考号 self.subjectId="" self.schoolId=self.conf["schoolid"] self.examinfo=[]
def studentIdList(self): self.studentIdlist=ljy_config.getconf().getstudentIdlist() return ljy_config.getconf().getstudentIdlist()
conf=self.conf # login_result=self.login() if conf["custommethod"]=="True": self.CustomMethod(httpMethod=conf["httpmethod"],params=conf["params"],uri=conf["uri"],data=conf["data"],headers_add=conf["headers_add"],cookies=conf["cookies"]) else: # self.getExamList() result=self.saveStudentAnswer() #self.logout() # file_path="C:\\Users\\povti\\Downloads\\导入学生帐号.xls" # self.Upload_MultipartFormData(file_path) stop_time=time.time() print("(%s)总共耗时:{0:.5f}秒>>执行结果(%s)".format(stop_time-self.start_time)%(self.studentId,result)) if __name__ == '__main__': c=ljy_config.getconf().get_config() try: for i in range(int(c["loop"])): passwd=c["passwd"] username="" start_time=time.time() a=common(i,username,passwd,start_time) target=threading.Thread(target=a.main) #这里的函数不要加() #threading.active_count()线程数量,手动限制每次开启的线程数量 while threading.active_count()>int(c["thread"]): time.sleep(10) target.start() #threading.Thread.__stop() except KeyboardInterrupt: print("key break!")
def getuserlist(self): return ljy_config.getconf().getuserlist()