Ejemplo n.º 1
0
    def geturl(self):
	    self.urls_time={}
	    self.url_lists=[] #二级资源排序使用
	    self.url_err_lists=[] #访问存在问题的二级资源列表
	    oldtime=datetime.datetime.now()-datetime.datetime.now()
	    for i in self.urls:
		    
		    senurl=checktime(urllib2.urlopen)
		    senurl.check(i)
		    #处理二级资源为err的内容到self.url_err_lists中
		    if (1 == self._errurl(i,senurl)):
			    continue
		
	            #处理正常返回的二级资源
		    newtime=senurl.getusetime()
		    self.url_lists.append({'url':i,'usetime':newtime})

		    if (oldtime>newtime):
			    #print i
			    #print "usetime is %s" % senurl.getusetime()
			    pass
		    else:
			    oldtime=senurl.getusetime()
			    self._maxusetimeurl=i

	    #self.__getlists()
	    return oldtime,self._maxusetimeurl
Ejemplo n.º 2
0
	def getbasictime(self):
		"""[popexizhi add] 19/12/14 dba交流结果,对5xx,4xx server 的返回值使用时间用120标识
		# 当前修改位置为访问all url的设置位置,潜在问题是如果非basic地址存在4xxx 或 5xx 就使整个返回time为过大内容
		# 依赖条件("" == self.geterr) 
		  self._usetime=120s
		"""
		self._stattime=datetime.datetime.now()
		a=checktime(urllib2.urlopen)
		a.check(self._basicurl)
		self._basiccon=a.getvalue()
		self._basictime=a.getusetime()
		if (""==a.gethttperr() ):
			#get sencond
			self.__getsencondtime()
		
			#save db
			#save err
			#a.save_check_err(tcid=str("TCID:"+str(self._stattime)))
		else:
			#获得e中的异常码,设置为httpcode
			(code,con)=str(a.gethttperr()).split(":")
			self.httpcode=re.sub(re.compile("\D"),"",code)
			#设置usetime=120s 
			self._totusetime=datetime.timedelta(seconds=120)
			self._basictime=datetime.timedelta(seconds=120)
Ejemplo n.º 3
0
	def test_MOREERR(self):
		#HTTP404 test
		a=checktime(urllib2.urlopen)
		for i in range(1,20):
			url='http://www.99114.com/sadfd'+str(i)
			a.check(url)
			a.get_time()
			a.save_check_err(tcid=str("unittest"+str(i)))
Ejemplo n.º 4
0
    def getbasictime(self):
        self._stattime = datetime.datetime.now()
        a = checktime(urllib2.urlopen)
        a.check(self._basicurl)
        self._basiccon = a.getvalue()
        self._basictime = a.getusetime()

        #get sencond
        self.__getsencondtime()

        #save db
        #save err
        a.save_check_err(tcid=str("TCID:" + str(self._stattime)))
	def getbasictime(self):
		self._stattime=datetime.datetime.now()
		a=checktime(urllib2.urlopen)
		a.check(self._basicurl)
		self._basiccon=a.getvalue()
		self._basictime=a.getusetime()

		#get sencond
		self.__getsencondtime()
		
		#save db
		#save err
		a.save_check_err(tcid=str("TCID:"+str(self._stattime)))
Ejemplo n.º 6
0
    def geturl(self):
        self.urls_time = {}
        oldtime = datetime.datetime.now() - datetime.datetime.now()
        for i in self.urls:
            senurl = checktime(urllib2.urlopen)
            senurl.check(i)
            if (oldtime > senurl.getusetime()):
                #print i
                #print "usetime is %s" % senurl.getusetime()
                pass
            else:
                oldtime = senurl.getusetime()
                self._maxusetimeurl = i

        return oldtime, self._maxusetimeurl
    def geturl(self):
	    self.urls_time={}
	    oldtime=datetime.datetime.now()-datetime.datetime.now()
	    for i in self.urls:
		    senurl=checktime(urllib2.urlopen)
		    senurl.check(i)
		    if (oldtime>senurl.getusetime()):
			    #print i
			    #print "usetime is %s" % senurl.getusetime()
			    pass
		    else:
			    oldtime=senurl.getusetime()
			    self._maxusetimeurl=i

	    return oldtime,self._maxusetimeurl
Ejemplo n.º 8
0
	def test_basic(self):
		a=checktime(urllib2.urlopen)
		a.check('http://www.99114.com')
		a.get_time()