예제 #1
0
 def get(self, request, package, format, *args, **kwargs):
     self.request = request
     self.format = format
     url = PYPI_URL % package
     r_data = redis.get(package)
     if r_data:
         self.package = json2package(r_data)
         return self.handle_package_data()
     try:
         response = requests.get(url)
         response.raise_for_status()
     except requests.exceptions.HTTPError as e:
         self.shield_subject = 'error'
         return self.write_shield('error', 'red')
     else:
         redis.set(package, response.content)
         redis.expire(package, REDIS_EXPIRE)
         self.package = json2package(response.content)
         return self.handle_package_data()
예제 #2
0
 def get(self, request, package, format, *args, **kwargs):
     self.request = request
     self.format = format
     url = PYPI_URL % package
     r_data = redis.get(package)
     if r_data:
         self.package = json2package(r_data)
         return self.handle_package_data()
     try:
         response = requests.get(url)
         response.raise_for_status()
     except requests.exceptions.HTTPError as e:
         self.shield_subject = 'error'
         return self.write_shield('error', 'red')
     else:
         redis.set(package, response.content)
         redis.expire(package, REDIS_EXPIRE)
         self.package = json2package(response.content)
         return self.handle_package_data()
 def setUp(self):
     package = os.path.join(os.path.dirname(__file__), "package.json")
     self.json = json.loads(open(package).read())
     self.package = json2package(open(package).read())
 def setUp(self):
     package = os.path.join(
         os.path.dirname(__file__), "package_no_homepage_bugtrack_one_release.json"
     )
     self.json = json.loads(open(package).read())
     self.package = json2package(open(package).read())
예제 #5
0
 def setUp(self):
     package = os.path.join(os.path.dirname(__file__),
                            'package_no_homepage_bugtrack_one_release.json')
     self.json = json.loads(open(package).read())
     self.package = json2package(open(package).read())
예제 #6
0
 def setUp(self):
     package = os.path.join(os.path.dirname(__file__),
                            'package.json')
     self.json = json.loads(open(package).read())
     self.package = json2package(open(package).read())