本文整理汇总了Python中voltcli.utility.abort函数的典型用法代码示例。如果您正苦于以下问题:Python abort函数的具体用法?Python abort怎么用?Python abort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了abort函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_required
def get_required(self, key):
value = self.get(key)
if value is None:
utility.abort('Configuration parameter "%s" was not found.' % key,
'Set parameters using the "config" command, for example:',
['%s config %s=VALUE' % (environment.command_name, key)])
return value
开发者ID:bear000s,项目名称:voltdb,代码行数:7,代码来源:runner.py
示例2: abort
def abort(self, *msgs):
"""
Display errors (optional) and abort execution.
"""
utility.error('Fatal error in "%s" command.' % self.verb.name, *msgs)
self.help()
utility.abort()
开发者ID:sumitk1,项目名称:voltdb,代码行数:7,代码来源:runner.py
示例3: __init__
def __init__(self, name, function, **kwargs):
CommandVerb.__init__(self, name, function, **kwargs)
self.modifiers = utility.kwargs_get_list(kwargs, 'modifiers', default = [])
if not self.modifiers:
utility.abort('Multi-command "%s" must provide a "modifiers" list.' % self.name)
valid_modifiers = '|'.join([mod.name for mod in self.modifiers])
has_args = 0
rows = []
for mod in self.modifiers:
if mod.arg_name:
usage = '%s %s [ %s ... ]' % (self.name, mod.name, mod.arg_name)
has_args += 1
else:
usage = '%s %s' % (self.name, mod.name)
rows.append((usage, mod.description))
caption = '"%s" Command Variations' % self.name
other_info = utility.format_table(rows, caption = caption, separator = ' ')
self.set_defaults(other_info = other_info.strip())
args = [
cli.StringArgument('modifier',
'command modifier (valid modifiers: %s)' % valid_modifiers)]
if has_args > 0:
if has_args == len(self.modifiers):
arg_desc = 'optional arguments(s)'
else:
arg_desc = 'optional arguments(s) (where applicable)'
args.append(cli.StringArgument('arg', arg_desc, min_count = 0, max_count = None))
self.add_arguments(*args)
开发者ID:AsherBond,项目名称:voltdb,代码行数:28,代码来源:verbs.py
示例4: go
def go(self, verb, runner):
if self.needs_catalog:
if runner.opts.replica:
self.subcommand = 'replica'
if self.supports_live:
if runner.opts.block:
final_args = [self.subcommand]
else:
final_args = ['live', self.subcommand]
else:
final_args = [self.subcommand]
if self.safemode_available:
if runner.opts.safemode:
final_args.extend(['safemode'])
if self.needs_catalog:
catalog = runner.opts.catalog
if not catalog:
catalog = runner.config.get('volt.catalog')
if catalog is None:
utility.abort('A catalog path is required.')
final_args.extend(['catalog', catalog])
if runner.opts.deployment:
final_args.extend(['deployment', runner.opts.deployment])
if runner.opts.host:
final_args.extend(['host', runner.opts.host])
else:
utility.abort('host is required.')
if runner.opts.clientport:
final_args.extend(['port', runner.opts.clientport])
if runner.opts.adminport:
final_args.extend(['adminport', runner.opts.adminport])
if runner.opts.httpport:
final_args.extend(['httpport', runner.opts.httpport])
if runner.opts.license:
final_args.extend(['license', runner.opts.license])
if runner.opts.internalinterface:
final_args.extend(['internalinterface', runner.opts.internalinterface])
if runner.opts.internalport:
final_args.extend(['internalport', runner.opts.internalport])
if runner.opts.replicationport:
final_args.extend(['replicationport', runner.opts.replicationport])
if runner.opts.zkport:
final_args.extend(['zkport', runner.opts.zkport])
if runner.opts.externalinterface:
final_args.extend(['externalinterface', runner.opts.externalinterface])
if runner.args:
final_args.extend(runner.args)
kwargs = {}
if self.supports_daemon and runner.opts.daemon:
# Provide a default description if not specified.
daemon_description = self.daemon_description
if daemon_description is None:
daemon_description = "VoltDB server"
# Initialize all the daemon-related keyword arguments.
runner.setup_daemon_kwargs(kwargs, name=self.daemon_name,
description=daemon_description,
output=self.daemon_output)
self.run_java(verb, runner, *final_args, **kwargs)
开发者ID:mindis,项目名称:voltdb,代码行数:60,代码来源:verbs.py
示例5: postprocess_value
def postprocess_value(self, value):
if type(value) is not int:
try:
converted = int(value.strip())
except ValueError:
utility.abort('Bad "%s" integer value: %s' % (self.get_dest().upper(), value))
return converted
return value
开发者ID:migue,项目名称:voltdb,代码行数:8,代码来源:cli.py
示例6: call_proc
def call_proc(self, sysproc_name, types, args, check_status = True):
utility.verbose_info('Call procedure: %s%s' % (sysproc_name, tuple(args)))
proc = voltdbclient.VoltProcedure(self.client, sysproc_name, types)
response = proc.call(params = args)
if check_status and response.status != 1:
utility.abort('"%s" procedure call failed.' % sysproc_name, (response,))
utility.verbose_info(response)
return utility.VoltResponseWrapper(response)
开发者ID:sumitk1,项目名称:voltdb,代码行数:8,代码来源:runner.py
示例7: go
def go(self, runner):
gofound = False
for bundle in self.bundles:
if hasattr(bundle, "go"):
bundle.go(self, runner)
gofound = True
if not gofound:
utility.abort("go() method is not implemented by any bundle or %s." % self.__class__.__name__)
开发者ID:royxhl,项目名称:voltdb,代码行数:8,代码来源:verbs.py
示例8: go
def go(self):
"""
Invoke the default function provided by a Verb object.
"""
if self.default_func is None:
utility.abort('Verb "%s" (class %s) does not provide a default go() function.'
% (self.verb.name, self.verb.__class__.__name__))
else:
self.default_func(self)
开发者ID:bear000s,项目名称:voltdb,代码行数:9,代码来源:runner.py
示例9: add_verb_options
def add_verb_options(self, verb):
"""
Add options for verb command line.
"""
for option in verb.iter_options():
try:
self.add_option(*option.get_option_names(), **option.kwargs)
except Exception, e:
utility.abort('Exception initializing options for verb "%s".' % verb.name, e)
开发者ID:TeaTips,项目名称:voltdb,代码行数:9,代码来源:cli.py
示例10: start
def start(self, verb, runner):
try:
kwargs = {}
if runner.opts.username:
kwargs['username'] = runner.opts.username
if runner.opts.password:
kwargs['password'] = runner.opts.password
runner.client = FastSerializer(runner.opts.host.host, runner.opts.host.port, **kwargs)
except Exception, e:
utility.abort(e)
开发者ID:AsherBond,项目名称:voltdb,代码行数:10,代码来源:verbs.py
示例11: process_outputfile_args
def process_outputfile_args(runner):
if runner.opts.output and runner.opts.prefix:
utility.abort('Cannot specify both --output and --prefix. Please use --output option.')
if runner.opts.output:
runner.args.extend(['--outputFile=' + runner.opts.output])
elif runner.opts.prefix:
utility.warning('Specifying prefix for outputfile name is deprecated. Consider using --output option to specify'
' output file name.')
runner.args.extend(['--prefix=' + runner.opts.prefix])
开发者ID:aamadeo27,项目名称:voltdb,代码行数:10,代码来源:collect.py
示例12: collect
def collect(runner):
if int(runner.opts.days) == 0:
utility.abort(' \'0\' is invalid entry for option --days')
process_voltdbroot_args(runner)
process_outputfile_args(runner)
runner.args.extend(['--dryrun=' + str(runner.opts.dryrun), '--skipheapdump=' + str(runner.opts.skipheapdump),
'--days=' + str(runner.opts.days), '--force=' + str(runner.opts.force)])
runner.java_execute('org.voltdb.utils.Collector', None, *runner.args)
开发者ID:aamadeo27,项目名称:voltdb,代码行数:10,代码来源:collect.py
示例13: postprocess_value
def postprocess_value(self, value):
bad = []
converted = []
for v in value.split(','):
try:
converted.append(int(v.strip()))
except ValueError:
bad.append(v.strip())
if bad:
utility.abort('Bad "%s" integer list value(s):' % self.get_dest().upper(), bad)
return converted
开发者ID:TeaTips,项目名称:voltdb,代码行数:11,代码来源:cli.py
示例14: call_proc
def call_proc(self, sysproc_name, types, args, check_status = True):
if self.client is None:
utility.abort('Command is not set up as a client.',
'Add an appropriate admin or client bundle to @VOLT.Command().')
utility.verbose_info('Call procedure: %s%s' % (sysproc_name, tuple(args)))
proc = voltdbclient.VoltProcedure(self.client, sysproc_name, types)
response = proc.call(params = args)
if check_status and response.status != 1:
utility.abort('"%s" procedure call failed.' % sysproc_name, (response,))
utility.verbose_info(response)
return utility.VoltResponseWrapper(response)
开发者ID:bear000s,项目名称:voltdb,代码行数:11,代码来源:runner.py
示例15: __init__
def __init__(self, runner, config):
self.runner = runner
self.config = config
if config.source_type != 'mysql':
utility.abort('Unsupported source type "%s".' % config.source_type,
'Only "mysql" is valid.')
output_files = [config.ddl_file, config.deployment_file, config.run_script]
overwrites = [p for p in output_files if os.path.exists(p)]
if overwrites and not runner.opts.overwrite:
utility.abort('Output files exist, delete or use the overwrite option.', overwrites)
utility.FileGenerator.__init__(self, self, **config)
开发者ID:YUFAN2GA,项目名称:voltdb,代码行数:11,代码来源:voltify.py
示例16: find_resource
def find_resource(self, name, required=False):
"""
Find a resource file.
"""
if self.verbspace.scan_dirs:
for scan_dir in self.verbspace.scan_dirs:
path = os.path.join(scan_dir, name)
if os.path.exists(path):
return path
if required:
utility.abort('Resource file "%s" is missing.' % name)
return None
开发者ID:bear000s,项目名称:voltdb,代码行数:12,代码来源:runner.py
示例17: main
def main(command_name, command_dir, version, description, *args, **kwargs):
#===============================================================================
"""
Called by running script to execute command with command line arguments.
"""
# The "package" keyword flags when running from a package zip __main__.py.
package = utility.kwargs_get_boolean(kwargs, 'package', default=False)
# The "standalone" keyword allows environment.py to skip the library search.
standalone = utility.kwargs_get_boolean(kwargs, 'standalone', default=False)
# The "state_directory" keyword overrides ~/.<command_name> as the
# directory used for runtime state files.
state_directory = utility.kwargs_get_string(kwargs, 'state_directory', default=None)
try:
# Pre-scan for verbose, debug, and dry-run options so that early code
# can display verbose and debug messages, and obey dry-run.
opts = cli.preprocess_options(base_cli_spec.options, args)
utility.set_verbose(opts.verbose)
utility.set_debug(opts.debug)
# Load the configuration and state
permanent_path = os.path.join(os.getcwd(), environment.config_name)
local_path = os.path.join(os.getcwd(), environment.config_name_local)
config = VoltConfig(permanent_path, local_path)
# Initialize the environment
environment.initialize(standalone, command_name, command_dir, version)
# Initialize the state directory (for runtime state files).
if state_directory is None:
state_directory = '~/.%s' % environment.command_name
state_directory = os.path.expandvars(os.path.expanduser(state_directory))
utility.set_state_directory(state_directory)
# Search for modules based on both this file's and the calling script's location.
verbspace = load_verbspace(command_name, command_dir, config, version,
description, package)
# Make internal commands available to user commands via runner.verbspace().
internal_verbspaces = {}
if command_name not in internal_commands:
for internal_command in internal_commands:
internal_verbspace = load_verbspace(internal_command, None, config, version,
'Internal "%s" command' % internal_command,
package)
internal_verbspaces[internal_command] = internal_verbspace
# Run the command
run_command(verbspace, internal_verbspaces, config, *args)
except KeyboardInterrupt:
sys.stderr.write('\n')
utility.abort('break')
开发者ID:bear000s,项目名称:voltdb,代码行数:52,代码来源:runner.py
示例18: process_verb_arguments
def process_verb_arguments(self, verb, verb_args, verb_opts):
"""
Validate the verb arguments. Check that required arguments are present
and populate verb_opts attributes with scalar values or lists (for
trailing arguments with max_count > 1).
"""
# Add fixed arguments passed in through the decorator to the verb object.
args = copy.copy(verb_args) + verb.command_arguments
# Set attributes for required arguments.
missing = []
exceptions = []
iarg = 0
nargs = verb.get_argument_count()
for arg in verb.iter_arguments():
# It's missing if we've exhausted all the arguments before
# exhausting all the argument specs, unless it's the last argument
# spec and it's optional.
if iarg > len(args) or (iarg == len(args) and arg.min_count > 0):
if not arg.optional:
missing.append((arg.name, arg.help))
else:
setattr(verb_opts, arg.name, None)
iarg +=1
else:
value = None
# The last argument can have repeated arguments. If more than
# one are allowed the values are put into a list.
if iarg == nargs - 1 and arg.max_count > 1:
if len(args) - iarg < arg.min_count:
utility.abort('A minimum of %d %s arguments are required.'
% (arg.min_count, arg.name.upper()))
if len(args) - iarg > arg.max_count:
utility.abort('A maximum of %d %s arguments are allowed.'
% (arg.max_count, arg.name.upper()))
# Pass through argument class get() for validation, conversion, etc..
# Skip bad values and report on them at the end.
value = []
for v in args[iarg:]:
try:
value.append(arg.get(v))
except ArgumentException, e:
exceptions.append(e)
iarg = len(args)
elif len(args) > 0:
# All other arguments are treated as scalars.
# Pass through argument class get() for validation, conversion, etc..
try:
value = arg.get(args[iarg])
except ArgumentException, e:
exceptions.append(e)
iarg += 1
开发者ID:migue,项目名称:voltdb,代码行数:51,代码来源:cli.py
示例19: voltdb_connect
def voltdb_connect(self, host, port, username=None, password=None):
"""
Create a VoltDB client connection.
"""
self.voltdb_disconnect()
try:
kwargs = {}
if username:
kwargs['username'] = username
if password:
kwargs['password'] = password
self.client = FastSerializer(host, port, **kwargs)
except Exception, e:
utility.abort(e)
开发者ID:kumarrus,项目名称:voltdb,代码行数:14,代码来源:runner.py
示例20: check_missing_items
def check_missing_items(type_name, missing_items):
#===============================================================================
"""
Look at item list with (name, description) pairs and abort with a useful
error message if the list isn't empty.
"""
if missing_items:
if len(missing_items) > 1:
plural = 's'
else:
plural = ''
fmt = '%%-%ds %%s' % max([len(o) for (o, h) in missing_items])
utility.abort('Missing required %s%s:' % (type_name, plural),
(fmt % (o.upper(), h) for (o, h) in missing_items))
开发者ID:sumitk1,项目名称:voltdb,代码行数:14,代码来源:cli.py
注:本文中的voltcli.utility.abort函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论