def rm_source(self): sources = self.app.db['sources'] if not len(self.app.pargs.extra) >= 1: raise boss_exc.BossArgumentError("Repository name required.") elif self.app.pargs.extra[0] not in sources: raise boss_exc.BossArgumentError("Unknown source repository.") cache = sources[self.app.pargs.extra[0]]['cache'] if os.path.exists(cache): shutil.rmtree(cache) del sources[self.app.pargs.extra[0]] self.app.db['sources'] = sources
def test_boss_argument_error(self): try: raise exc.BossArgumentError("BossArgumentError Test") except exc.BossArgumentError as e: test.eq(e.msg, "BossArgumentError Test") test.eq(e.__str__(), "BossArgumentError Test") raise
def clean(self): if not len(self.app.pargs.extra) >= 1: raise boss_exc.BossArgumentError("Project path required.") for items in os.walk(self.app.pargs.extra[0]): for _file in items[2]: path = fs.abspath(os.path.join(items[0], _file)) if re.match('(.*)\.boss\.bak(.*)', path): self.app.log.warn("Removing: %s" % _file) os.remove(path)
def create(self): if not len(self.app.pargs.extra) >= 1: raise boss_exc.BossArgumentError("Destination path required.") if not self.app.pargs.template: raise boss_exc.BossArgumentError("Template label required.") sources = self.app.db.get('sources') try: tmpl_parts = self.app.pargs.template.split(':') source = tmpl_parts[0] template = tmpl_parts[1] except IndexError as e: source = 'boss' template = self.app.pargs.template src = SourceManager(self.app) src.create_from_template(source, template, self.app.pargs.extra[0])
def add_source(self): if not len(self.app.pargs.extra) >= 2: raise boss_exc.BossArgumentError("Repository name and path " + \ "required.") sources = self.app.db['sources'] label = self.app.pargs.extra[0] path = self.app.pargs.extra[1] cache_dir = mkdtemp(dir=self.app.config.get('boss', 'cache_dir')) if self.app.pargs.local: path = fs.abspath(path) sources[label] = dict( label=label, path=path, cache=cache_dir, is_local=self.app.pargs.local, last_sync_time='never' ) self.app.db['sources'] = sources
def default(self): raise boss_exc.BossArgumentError("A sub-command is required. " "Please see --help.")