def postOptions(self): if self['repository'] is None: raise usage.error("You must pass --repository") if self._includes: self['includes'] = '(%s)' % ('|'.join(self._includes), ) if self._excludes: self['excludes'] = '(%s)' % ('|'.join(self._excludes), )
def opt_port(self, opt): """set the port to listen on """ try: self.portno = int(opt) except ValueError: raise usage.error("Invalid argument to 'port'!")
def parseIP(addr): """Wraps IP() to throw usage.error instead of ValueError.""" try: return IP(str(addr)) except ValueError: raise usage.error("Not an IP address", addr)
def postOptions(self): if resource is not None and not self['force-limits']: total_pool_size = sum(self['conf'].get('pools', {}).values()) soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) if soft_limit < total_pool_size: raise usage.error( 'fd limit %d < %d, use --force-limits to override' % (soft_limit, total_pool_size))
def main(args): config = FuseTestsOptions() config.parseOptions(args[1:]) target = 'all' if len(args) > 1: target = args.pop(1) test_type = config['test-type'] if test_type not in ('both', 'unit', 'system'): raise usage.error('test-type %r not supported' % (test_type,)) if test_type in ('both', 'unit'): run_unit_tests([args[0]]) if test_type in ('both', 'system'): return run_system_test(config)
def postOptions(self): if self['repository'] is None: raise usage.error("You must pass --repository")
def opt_port(self, opt): try: self.portno = int(opt) except ValueError: raise usage.error("Invalid argument to 'port'!")
def parseArgs(self, conffile): try: with open(conffile, 'rb') as f: self['conf'] = yaml.safe_load(f) except EnvironmentError as e: raise usage.error('Cannot open %s: %s' % (conffile, e))
def parseArgs(self, *names): if not names: raise usage.error("No one to block ;(") self["blockees"] = names