def add(self, overlay): ''' Add an overlay to the local list of overlays. ''' if overlay.name not in self.overlays.keys(): if not self._check_official(overlay): return False result = overlay.add(self.config['storage']) if result == 0: if 'priority' in self.config.keys(): overlay.set_priority(self.config['priority']) self.overlays[overlay.name] = overlay self.write(self.path) repo_ok = self.repo_conf.add(overlay) if False in repo_ok: return False return True else: mdir = path([self.config['storage'], overlay.name]) delete_empty_directory(mdir, self.output) if os.path.exists(mdir): self.output.error('Adding repository "%s" failed!' ' Possible remains of the operation have NOT' ' been removed and may be left at "%s".' ' Please remove them manually if required.' \ % (overlay.name, mdir)) return False else: self.output.error( 'Adding repository "%s" failed!' % overlay.name) return False else: self.output.error('Repository "' + overlay.name + '" already in the local (installed) list!') return False
def add(self, overlay): ''' Add an overlay to the local list of overlays. ''' if overlay.name not in self.overlays.keys(): if not self._check_official(overlay): return False result = overlay.add(self.config['storage']) if result == 0: if 'priority' in self.config.keys(): overlay.set_priority(self.config['priority']) self.overlays[overlay.name] = overlay self.write(self.path) repo_ok = self.repo_conf.add(overlay) if False in repo_ok: return False return True else: mdir = path([self.config['storage'], overlay.name]) delete_empty_directory(mdir, self.output) if os.path.exists(mdir): self.output.error('Adding repository "%s" failed!' ' Possible remains of the operation have NOT' ' been removed and may be left at "%s".' ' Please remove them manually if required.' \ % (overlay.name, mdir)) return False else: self.output.error('Adding repository "%s" failed!' % overlay.name) return False else: self.output.error('Repository "' + overlay.name + '" already in the local (installed) list!') return False
def add(self, overlay): ''' Add an overlay to the local list of overlays. >>> import tempfile >>> tmpdir = tempfile.mkdtemp(prefix="laymantmp_") >>> write = os.path.join(tmpdir, 'installed.xml') >>> write2 = os.path.join(tmpdir, 'make.conf') >>> here = os.path.dirname(os.path.realpath(__file__)) >>> from layman.config import OptionConfig >>> myoptions = {'installed' : ... here + '/tests/testfiles/global-overlays.xml', ... 'local_list': here + '/tests/testfiles/overlays.xml', ... 'make_conf' : write2, ... 'nocheck' : 'yes', ... 'storage' : tmpdir} >>> config = OptionConfig(myoptions) >>> config.set_option('quietness', 3) >>> a = DB(config) >>> config.set_option('installed', write) >>> b = DB(config) >>> config['output'].set_colorize(False) >>> m = MakeConf(config, b.overlays) >>> m.path = write2 >>> success = m.write() >>> success True # Commented out since it needs network access: # >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS # * Running command "/usr/bin/rsync -rlptDvz --progress --delete --delete-after --timeout=180 --exclude="distfiles/*" --exclude="local/*" --exclude="packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*" "/tmp/file.../wrobel-stable""... # >>> c = DbBase([write, ], dict()) # >>> c.overlays.keys() # ['wrobel-stable'] # >>> m = MakeConf(config, b.overlays) # >>> [i.name for i in m.overlays] #doctest: +ELLIPSIS # ['wrobel-stable'] # >>> os.unlink(write) >>> os.unlink(write2) >>> import shutil >>> shutil.rmtree(tmpdir) ''' if overlay.name not in self.overlays.keys(): if not self._check_official(overlay): return False result = overlay.add(self.config['storage']) if result == 0: if 'priority' in self.config.keys(): overlay.set_priority(self.config['priority']) self.overlays[overlay.name] = overlay self.write(self.path) repo_ok = self.repo_conf.add(overlay) if False in repo_ok: return False return True else: mdir = path([self.config['storage'], overlay.name]) delete_empty_directory(mdir, self.output) if os.path.exists(mdir): self.output.error('Adding repository "%s" failed!' ' Possible remains of the operation have NOT' ' been removed and may be left at "%s".' ' Please remove them manually if required.' \ % (overlay.name, mdir)) return False else: self.output.error( 'Adding repository "%s" failed!' % overlay.name) return False else: self.output.error('Repository "' + overlay.name + '" already in the local (installed) list!') return False