Loading installsystems/repository.py +28 −20 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ class Repository(object): def __init__(self, config): self.config = config if not config.offline: try: self.db = Database(config.dbpath) except: self.db = None self.config.offline = True if config.offline: debug("Repository %s is offline" % config.name) def __getattribute__(self, name): ''' Loading @@ -38,14 +41,13 @@ class Repository(object): Unavailable can be caused because db is not accessible or because repository is not initialized ''' db = object.__getattribute__(self, "db") config = object.__getattribute__(self, "config") # config and init are always accessible if name in ("init", "config"): return object.__getattribute__(self, name) # if no db (not init or not accessible) raise error if db is None: raise Exception("Repository %s is not availabe" % config.name) if config.offline: raise Exception("Repository %s is offline" % config.name) return object.__getattribute__(self, name) def init(self): Loading Loading @@ -318,6 +320,7 @@ class RepositoryConfig(object): # set default value for arguments self.name = name self.path = "" self.offline = False self._dbpath = None self.dbname = "db" self._lastpath = None Loading Loading @@ -564,7 +567,9 @@ class RepositoryManager(object): if not os.path.exists(filedest): open(filedest, "wb") # get remote last value try: rlast = int(istools.uopen(config.lastpath).read().strip()) # get local last value llast = int(os.stat(filedest).st_mtime) # if repo is out of date, download it Loading @@ -577,6 +582,9 @@ class RepositoryManager(object): timeout=self.timeout) os.utime(filedest, (rlast, rlast)) config.dbpath = filedest except: # if something append bad during caching, we mark repo as offline config.offline = True return Repository(config) def get(self, name, version=None): Loading Loading
installsystems/repository.py +28 −20 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ class Repository(object): def __init__(self, config): self.config = config if not config.offline: try: self.db = Database(config.dbpath) except: self.db = None self.config.offline = True if config.offline: debug("Repository %s is offline" % config.name) def __getattribute__(self, name): ''' Loading @@ -38,14 +41,13 @@ class Repository(object): Unavailable can be caused because db is not accessible or because repository is not initialized ''' db = object.__getattribute__(self, "db") config = object.__getattribute__(self, "config") # config and init are always accessible if name in ("init", "config"): return object.__getattribute__(self, name) # if no db (not init or not accessible) raise error if db is None: raise Exception("Repository %s is not availabe" % config.name) if config.offline: raise Exception("Repository %s is offline" % config.name) return object.__getattribute__(self, name) def init(self): Loading Loading @@ -318,6 +320,7 @@ class RepositoryConfig(object): # set default value for arguments self.name = name self.path = "" self.offline = False self._dbpath = None self.dbname = "db" self._lastpath = None Loading Loading @@ -564,7 +567,9 @@ class RepositoryManager(object): if not os.path.exists(filedest): open(filedest, "wb") # get remote last value try: rlast = int(istools.uopen(config.lastpath).read().strip()) # get local last value llast = int(os.stat(filedest).st_mtime) # if repo is out of date, download it Loading @@ -577,6 +582,9 @@ class RepositoryManager(object): timeout=self.timeout) os.utime(filedest, (rlast, rlast)) config.dbpath = filedest except: # if something append bad during caching, we mark repo as offline config.offline = True return Repository(config) def get(self, name, version=None): Loading