本文整理汇总了Python中voltcli.utility.abort函数的典型用法代码示例。如果您正苦于以下问题:Python abort函数的具体用法?Python abort怎么用?Python abort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了abort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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()
示例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)
示例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)
示例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
示例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)
示例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__)
示例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)
示例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)
示例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)
示例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])
示例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)
示例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
示例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)
示例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)