예제 #1
0
 def testAll200(self):
     """return True if site always returns 200
     """
     r1 = self.get(md5(random.randint()))
     r2 = self.get(md5(random.randint()) + '/' + md5(random.randint()))
     if r1.status_code == 200 and r2.status_code == 200:
         return True
     return False
예제 #2
0
파일: sess.py 프로젝트: LubyRuffy/Saker
 def cacheGet(self, path="", cachefile=None):
     if cachefile is None:
         cachefile = '.%s.html' % md5(path)
     if os.path.exists(cachefile):
         self.logger.debug('cache %s hit' % path)
         with open(cachefile, 'rb') as fh:
             return fh.read()
     else:
         self.get(path)
         self.logger.debug('cache save %s to file %s' % (path, cachefile))
         with open(cachefile, 'wb') as fh:
             fh.write(self.lastr.content)
             return self.lastr.content
예제 #3
0
파일: request.py 프로젝트: optionalg/Saker
 def brief(self):
     if self.lastr is None:
         return "Exception"
     msg = "\t".join(
         map(str, [
             self.lastr.status_code,
             len(self.lastr.content), self.interval,
             md5(self.lastr.content)[:8]
         ]))
     if self.lastr.status_code // 100 == 5:
         return red(msg)
     elif self.lastr.status_code // 100 == 4:
         return cyan(msg)
     elif self.lastr.status_code // 100 == 3:
         return green(msg)
     else:
         return msg