예제 #1
0
class Pypi(object):
    __inst = None
    
    def __new__(cls):
        if cls.__inst is None:
            cls.__inst = object.__new__(cls)
        return cls.__inst
    
    def __init__(self):
        self.pypi_proxy = PypiProxy()
        self.package_list = Lica("package list", 
                                 backend=DictBackend,
                                 timespan=td(hours=12))
        self.version_info = Lica("version_infos", 
                                 backend=SqliteBackend, 
                                 path='cache/pypirss.db',
                                 timespan=0)
        self.package_versions = Lica("package_versions", 
                                     backend=SqliteBackend, 
                                     path='cache/pypirss.db',
                                     timespan=td(hours=12))
    def get_package_list(self):
        package_list, outdated = self.package_list.get('full_list',
                                                       fallback=True)
        if outdated == True:
            try:
                updated_list = self.pypi_proxy.get_package_list()
            except DataUnavailable, err:
                if package_list is None:
                    raise err
            else:
                package_list = updated_list
                self.package_list.put('full_list', updated_list)
        return package_list
예제 #2
0
 def __init__(self):
     self.pypi_proxy = PypiProxy()
     self.package_list = Lica("package list", 
                              backend=DictBackend,
                              timespan=td(hours=12))
     self.version_info = Lica("version_infos", 
                              backend=SqliteBackend, 
                              path='cache/pypirss.db',
                              timespan=0)
     self.package_versions = Lica("package_versions", 
                                  backend=SqliteBackend, 
                                  path='cache/pypirss.db',
                                  timespan=td(hours=12))