module documentation

Module dealing with command line parsing

Class ArgChoice Choice argument.
Class ArgCommand Command argument.
Class ArgExtStorage ExtStorage argument.
Class ArgFile File path argument.
Class ArgFilter Filter UUID argument.
Class ArgGroup Node group argument.
Class ArgHost Host argument.
Class ArgInstance Instances argument.
Class ArgJobId Job ID argument.
Class ArgNetwork Network argument.
Class ArgNode Node argument.
Class ArgOs OS argument.
Class ArgSuggest Suggesting argument.
Class ArgUnknown Unknown argument to program (e.g. determined at runtime).
Class FeedbackFnJobPollReportCb No class docstring; 0/1 instance variable, 3/3 methods documented
Class JobExecutor Class which manages the submission and execution of multiple jobs.
Class JobPollCbBase Base class for GenericPollJob callbacks.
Class JobPollReportCbBase Base class for GenericPollJob reporting callbacks.
Class StdioJobPollReportCb No class docstring; 0/2 instance variable, 3/3 methods documented
Class TableColumn Describes a column for FormatTable.
Function AddTags Add tags on a given object.
Function AskUser Ask the user a question.
Function CalculateOSNames Calculates all the names an OS can be called, according to its variants.
Function ConfirmOperation Ask the user to confirm an operation on a list of list_type.
Function CreateIPolicyFromOpts Creation of instance policy based on command line options.
Function FixHvParams Undocumented
Function FormatError Return a formatted error message for a given error.
Function FormatLogMessage Formats a job message according to its type.
Function FormatParamsDictInfo Formats a parameter dictionary.
Function FormatPolicyInfo Formats an instance policy.
Function FormatQueryResult Formats data in objects.QueryResponse.
Function FormatResultError Formats result status other than constants.RS_NORMAL.
Function FormatTable Formats data as a table.
Function FormatTimestamp Formats a given timestamp.
Function GenerateTable Prints a table with headers and different fields.
Function GenericInstanceCreate Add an instance to the cluster via either creation or import.
Function GenericList Generic implementation for listing all items of a resource.
Function GenericListFields Generic implementation for listing fields for a resource.
Function GenericMain Generic main function for all the gnt-* commands.
Function GenericPollJob Generic job-polling function.
Function GetNodesSshPorts Retrieves SSH ports of given nodes.
Function GetNodeUUIDs Retrieves the UUIDs of given nodes.
Function GetOnlineNodes Returns the names of online nodes.
Function ListTags List the tags on a given object.
Function ParseFields Parses the values of "--field"-like options.
Function ParseNicOption Parses the value of the --net option(s).
Function ParseTimespec Parse a time specification.
Function PollJob Function to poll for the result of a job.
Function PrintGenericInfo Print information formatted according to the hierarchy.
Function PrintIPolicyCommand Print the command option used to generate the given instance policy.
Function RemoveTags Remove tags from a given object.
Function RunWhileClusterStopped Calls a function while all cluster daemons are stopped.
Function RunWhileDaemonsStopped Calls a function while all cluster daemons are stopped.
Function SendJob Function to submit an opcode without waiting for the results.
Function SetGenericOpcodeOpts Processor for generic options.
Function SplitNodeOption Splits the value of a --node option.
Function SubmitOpCode Legacy function to submit an opcode.
Function SubmitOpCodeToDrainedQueue Forcefully insert a job in the queue, even if it is drained.
Function SubmitOrSend Wrapper around SubmitOpCode or SendJob.
Function ToStderr Write a message to stderr only, bypassing the logging system
Function ToStdout Write a message to stdout only, bypassing the logging system
Function ToStdoutAndLoginfo Write a message to stdout and additionally log it at INFO level
Constant ARGS_MANY_FILTERS Undocumented
Constant ARGS_MANY_GROUPS Undocumented
Constant ARGS_MANY_INSTANCES Undocumented
Constant ARGS_MANY_NETWORKS Undocumented
Constant ARGS_MANY_NODES Undocumented
Constant ARGS_NONE Undocumented
Constant ARGS_ONE_FILTER Undocumented
Constant ARGS_ONE_GROUP Undocumented
Constant ARGS_ONE_INSTANCE Undocumented
Constant ARGS_ONE_NETWORK Undocumented
Constant ARGS_ONE_NODE Undocumented
Constant ARGS_ONE_OS Undocumented
Constant QR_INCOMPLETE Undocumented
Constant QR_NORMAL Undocumented
Constant QR_UNKNOWN Undocumented
Constant TISPECS_CLUSTER_TYPES Undocumented
Constant TISPECS_GROUP_TYPES Undocumented
Class _Argument Undocumented
Class _LuxiJobPollCb No class docstring; 0/1 instance variable, 4/4 methods documented
Class _QueryColumnFormatter Callable class for formatting fields of a query.
Class _RunWhileDaemonsStoppedHelper Helper class for RunWhileDaemonsStopped to simplify state management
Exception _ShowUsage Exception class for _ParseArgs.
Exception _ShowVersion Exception class for _ParseArgs.
Function _CheckArguments Verifies the arguments using the argument definition.
Function _ExtendTags Extend the args if a source file has been given.
Function _ExtractTagsObject Extract the tag type object.
Function _FieldDescValues Helper function for GenericListFields to get query field description.
Function _FormatBool Formats a boolean value as a string.
Function _FormatListInfoDefault Undocumented
Function _FormatUsage Generates a nice description of all commands.
Function _GetAlignmentMapping Returns info about alignment if present in an encoded ordered dictionary.
Function _GetColFormatString Returns the format string for a field.
Function _GetColumnFormatter Returns formatting function for a field.
Function _GetISpecsInAllowedValues Undocumented
Function _GetUnknownFields Returns list of unknown fields included in fdefs.
Function _InitISpecsFromFullOpts Undocumented
Function _InitISpecsFromSplitOpts Undocumented
Function _InitReasonTrail Builds the first part of the reason trail
Function _MaybeParseUnit Parses and returns an array of potential values with units.
Function _NotAContainer Checks whether the input is not a container data type.
Function _ParseArgs Parser for the command line arguments.
Function _ParseISpec Undocumented
Function _ParseSpecUnit Undocumented
Function _PrintSpecsParameters Undocumented
Function _SerializeGenericInfo Formatting core of PrintGenericInfo.
Function _ToStream Write a message to a stream, bypassing the logging system
Function _WarnUnknownFields Prints a warning to stderr if a query included unknown fields.
Constant _CHOOSE_BATCH Undocumented
Constant _DEFAULT_FORMAT_QUERY Undocumented
Constant _QFT_NAMES Undocumented
def AddTags(opts, args):

Add tags on a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

def AskUser(text, choices=None):

Ask the user a question.

Parameters
textthe question to ask
choiceslist with elements tuples (input_char, return_value, description); if not given, it will default to: [('y', True, 'Perform the operation'), ('n', False, 'Do no do the operation')]; note that the '?' char is reserved for help
Returns
one of the return values from the choices list; if input is not possible (i.e. not running with a tty, we return the last entry from the list
def CalculateOSNames(os_name, os_variants):

Calculates all the names an OS can be called, according to its variants.

Parameters
os_name:stringbase name of the os
os_variants:list or Nonelist of supported variants
Returns
listlist of valid names
def ConfirmOperation(names, list_type, text, extra=''):

Ask the user to confirm an operation on a list of list_type.

This function is used to request confirmation for doing an operation on a given list of list_type.

Parameters
names:listthe list of names that we display when we ask for confirmation
list_type:strHuman readable name for elements in the list (e.g. nodes)
text:strthe operation that the user should confirm
extraUndocumented
Returns
booleanTrue or False depending on user's confirmation.
def CreateIPolicyFromOpts(ispecs_mem_size=None, ispecs_cpu_count=None, ispecs_disk_count=None, ispecs_disk_size=None, ispecs_nic_count=None, minmax_ispecs=None, std_ispecs=None, ipolicy_disk_templates=None, ipolicy_vcpu_ratio=None, ipolicy_spindle_ratio=None, group_ipolicy=False, allowed_values=None, fill_all=False):

Creation of instance policy based on command line options.

Parameters
ispecs_mem_sizeUndocumented
ispecs_cpu_countUndocumented
ispecs_disk_countUndocumented
ispecs_disk_sizeUndocumented
ispecs_nic_countUndocumented
minmax_ispecsUndocumented
std_ispecsUndocumented
ipolicy_disk_templatesUndocumented
ipolicy_vcpu_ratioUndocumented
ipolicy_spindle_ratioUndocumented
group_ipolicyUndocumented
allowed_valuesUndocumented
fill_allwhether for cluster policies we should ensure that all values are filled
def FixHvParams(hvparams):

Undocumented

def FormatError(err):

Return a formatted error message for a given error.

This function takes an exception instance and returns a tuple consisting of two values: first, the recommended exit code, and second, a string describing the error message (not newline-terminated).

def FormatLogMessage(log_type, log_msg):

Formats a job message according to its type.

def FormatParamsDictInfo(param_dict, actual, roman=False):

Formats a parameter dictionary.

Parameters
param_dict:dictthe own parameters
actual:dictthe current parameter set (including defaults)
romanUndocumented
Returns
dictdictionary where the value of each parameter is either a fully formatted string or a dictionary containing formatted strings
def FormatPolicyInfo(custom_ipolicy, eff_ipolicy, iscluster, roman=False):

Formats an instance policy.

Parameters
custom_ipolicy:dictown policy
eff_ipolicy:dicteffective policy (including defaults); ignored for cluster
iscluster:boolthe policy is at cluster level
roman:boolwhether to print the values in roman numerals
Returns
list of pairsformatted data, suitable for PrintGenericInfo
def FormatQueryResult(result, unit=None, format_override=None, separator=None, header=False, verbose=False):

Formats data in objects.QueryResponse.

Parameters
result:objects.QueryResponseresult of query operation
unit:stringUnit used for formatting fields of type constants.QFT_UNIT, see utils.text.FormatUnit
format_override:dictDictionary for overriding field formatting functions, indexed by field name, contents like _DEFAULT_FORMAT_QUERY
separator:string or NoneString used to separate fields
header:boolWhether to output header row
verbose:booleanwhether to use verbose field descriptions or not
def FormatResultError(status, verbose):

Formats result status other than constants.RS_NORMAL.

Parameters
statusThe result status
verbose:booleanWhether to return the verbose text
Returns
Text of result status
def FormatTable(rows, columns, header, separator):

Formats data as a table.

Parameters
rows:list of listsRow data, one list per row
columns:list of TableColumnColumn descriptions
header:boolWhether to show header row
separator:string or NoneString used to separate columns
def FormatTimestamp(ts):

Formats a given timestamp.

Parameters
ts:timestampa timeval-type timestamp, a tuple of seconds and microseconds
Returns
stringa string with the formatted timestamp
def GenerateTable(headers, fields, separator, data, numfields=None, unitfields=None, units=None):

Prints a table with headers and different fields.

Parameters
headers:dictdictionary mapping field names to headers for the table
fields:listthe field names corresponding to each row in the data field
separatorthe separator to be used; if this is None, the default 'smart' algorithm is used which computes optimal field width, otherwise just the separator is used between each field
data:lista list of lists, each sublist being one row to be output
numfields:lista list with the fields that hold numeric values and thus should be right-aligned
unitfields:lista list with the fields that hold numeric values that should be formatted with the units field
units:string or Nonethe units we should use for formatting, or None for automatic choice (human-readable for non-separator usage, otherwise megabytes); this is a one-letter string
def GenericInstanceCreate(mode, opts, args):

Add an instance to the cluster via either creation or import.

Parameters
modeconstants.INSTANCE_CREATE or constants.INSTANCE_IMPORT
optsthe command line options selected by the user
args:listshould contain only one element, the new instance name
Returns
intthe desired exit code
def GenericList(resource, fields, names, unit, separator, header, cl=None, format_override=None, verbose=False, force_filter=False, namefield=None, qfilter=None, isnumeric=False):

Generic implementation for listing all items of a resource.

Parameters
resourceOne of constants.QR_VIA_LUXI
fields:list of stringsList of fields to query for
names:list of stringsNames of items to query for
unit:string or NoneUnit used for formatting fields of type constants.QFT_UNIT or None for automatic choice (human-readable for non-separator usage, otherwise megabytes); this is a one-letter string
separator:string or NoneString used to separate fields
header:boolWhether to show header row
clUndocumented
format_override:dictDictionary for overriding field formatting functions, indexed by field name, contents like _DEFAULT_FORMAT_QUERY
verbose:booleanwhether to use verbose field descriptions or not
force_filter:boolWhether to always treat names as filter
namefield:stringName of field to use for simple filters (see qlang.MakeFilter for details)
qfilter:list or NoneQuery filter (in addition to names)
isnumericWhether the namefield's type is numeric, and therefore any simple filters built by namefield should use integer values to reflect that
def GenericListFields(resource, fields, separator, header, cl=None):

Generic implementation for listing fields for a resource.

Parameters
resourceOne of constants.QR_VIA_LUXI
fields:list of stringsList of fields to query for
separator:string or NoneString used to separate fields
header:boolWhether to show header row
clUndocumented
def GenericMain(commands, override=None, aliases=None, env_override=frozenset()):

Generic main function for all the gnt-* commands.

Parameters
commandsa dictionary with a special structure, see the design doc for command line handling.
overrideif not None, we expect a dictionary with keys that will override command line options; this can be used to pass options from the scripts to generic functions
aliasesdictionary with command aliases {'alias': 'target, ...}
env_overridelist of environment names which are allowed to submit default args for commands
def GenericPollJob(job_id, cbs, report_cbs, cancel_fn=None, update_freq=constants.DEFAULT_WFJC_TIMEOUT):

Generic job-polling function.

Parameters
job_id:numberJob ID
cbs:Instance of JobPollCbBaseData callbacks
report_cbs:Instance of JobPollReportCbBaseReporting callbacks
cancel_fn:Function returning a booleanFunction to check if we should cancel the running job
update_freq:int/longnumber of seconds between each WFJC reports
Returns
the opresult of the job
Raises
errors.JobLostIf job can't be found
errors.JobCanceledIf job is canceled
errors.OpExecErrorIf job didn't succeed
def GetNodesSshPorts(nodes, cl):

Retrieves SSH ports of given nodes.

Parameters
nodes:a list of stringsthe names of nodes
cl:ganeti.luxi.Clienta client to use for the query
Returns
a list of tuplesthe list of SSH ports corresponding to the nodes
def GetNodeUUIDs(nodes, cl):

Retrieves the UUIDs of given nodes.

Parameters
nodes:a list of stringthe names of nodes
cl:ganeti.luxi.Clienta client to use for the query
Returns
a list of tuplesthe list of UUIDs corresponding to the nodes
def GetOnlineNodes(nodes, cl=None, nowarn=False, secondary_ips=False, filter_master=False, nodegroup=None):

Returns the names of online nodes.

This function will also log a warning on stderr with the names of the online nodes.

Parameters
nodesif not empty, use only this subset of nodes (minus the offline ones)
clif not None, luxi client to use
nowarn:booleanby default, this function will output a note with the offline nodes that are skipped; if this parameter is True the note is not displayed
secondary_ips:booleanif True, return the secondary IPs instead of the names, useful for doing network traffic over the replication interface (if any)
filter_master:booleanif True, do not return the master node in the list (useful in coordination with secondary_ips where we cannot check our node name against the list)
nodegroup:stringIf set, only return nodes in this node group
def ListTags(opts, args):

List the tags on a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

def ParseFields(selected, default):

Parses the values of "--field"-like options.

Parameters
selected:string or NoneUser-selected options
default:listDefault fields
def ParseNicOption(optvalue):

Parses the value of the --net option(s).

def ParseTimespec(value):

Parse a time specification.

The following suffixed will be recognized:

  • s: seconds
  • m: minutes
  • h: hours
  • d: day
  • w: weeks

Without any suffix, the value will be taken to be in seconds.

def PollJob(job_id, cl=None, feedback_fn=None, reporter=None, cancel_fn=None, update_freq=constants.DEFAULT_WFJC_TIMEOUT):

Function to poll for the result of a job.

Parameters
job_id:job identifiedthe job to poll for results
cl:luxi.Clientthe luxi client to use for communicating with the master; if None, a new client will be created
feedback_fnUndocumented
reporterUndocumented
cancel_fn:Function returning a booleanFunction to check if we should cancel the running job
update_freq:int/longnumber of seconds between each WFJC report
def PrintGenericInfo(data):

Print information formatted according to the hierarchy.

The output is a valid YAML string.

Parameters
data

the data to print. It's a hierarchical structure whose elements can be:

  • dictionaries, where keys are strings and values are of any of the types listed here
  • lists of tuples (key, value) or (key, value, alignment_group), where key is a string, value is of any of the types listed here, and alignment_group can be any hashable value; it's a way to encode ordered dictionaries; any entries sharing the same alignment group are aligned by appending whitespace before the value as needed
  • lists of any of the types listed here
  • strings
def PrintIPolicyCommand(buf, ipolicy, isgroup):

Print the command option used to generate the given instance policy.

Currently only the parts dealing with specs are supported.

Parameters
buf:StringIOstream to write into
ipolicy:dictinstance policy
isgroup:boolwhether the policy is at group level
def RemoveTags(opts, args):

Remove tags from a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

def RunWhileClusterStopped(feedback_fn, fn, *args):

Calls a function while all cluster daemons are stopped.

Parameters
feedback_fn:callableFeedback function
fn:callableFunction to be called when daemons are stopped
*argsUndocumented
def RunWhileDaemonsStopped(feedback_fn, exclude_daemons, fn, *args, **kwargs):

Calls a function while all cluster daemons are stopped.

Parameters
feedback_fn:callableFeedback function
exclude_daemons:list of stringlist of daemons that stopped, but immediately restarted on the master to be available when calling 'fn'. If None, all daemons will be stopped and none will be started before calling 'fn'.
fn:callableFunction to be called when daemons are stopped
*argsUndocumented
**kwargsUndocumented
def SendJob(ops, cl=None):

Function to submit an opcode without waiting for the results.

Parameters
ops:listlist of opcodes
cl:luxi.Clientthe luxi client to use for communicating with the master; if None, a new client will be created
def SetGenericOpcodeOpts(opcode_list, options):

Processor for generic options.

This function updates the given opcodes based on generic command line options (like debug, dry-run, etc.).

Parameters
opcode_listlist of opcodes
optionscommand line options or None
Returns
None (in-place modification)
def SplitNodeOption(value):

Splits the value of a --node option.

def SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None):

Legacy function to submit an opcode.

This is just a simple wrapper over the construction of the processor instance. It should be extended to better handle feedback and interaction functions.

def SubmitOpCodeToDrainedQueue(op):

Forcefully insert a job in the queue, even if it is drained.

def SubmitOrSend(op, opts, cl=None, feedback_fn=None):

Wrapper around SubmitOpCode or SendJob.

This function will decide, based on the 'opts' parameter, whether to submit and wait for the result of the opcode (and return it), or whether to just send the job and print its identifier. It is used in order to simplify the implementation of the '--submit' option.

It will also process the opcodes if we're sending the via SendJob (otherwise SubmitOpCode does it).

def ToStderr(txt, *args):

Write a message to stderr only, bypassing the logging system

This is just a wrapper over _ToStream.

Parameters
txt:strthe message
*argsUndocumented
def ToStdout(txt, *args):

Write a message to stdout only, bypassing the logging system

This is just a wrapper over _ToStream.

Parameters
txt:strthe message
*argsUndocumented
def ToStdoutAndLoginfo(txt, *args):

Write a message to stdout and additionally log it at INFO level

ARGS_MANY_FILTERS =

Undocumented

Value
[ArgFilter()]
ARGS_MANY_GROUPS =

Undocumented

Value
[ArgGroup()]
ARGS_MANY_INSTANCES =

Undocumented

Value
[ArgInstance()]
ARGS_MANY_NETWORKS =

Undocumented

Value
[ArgNetwork()]
ARGS_MANY_NODES =

Undocumented

Value
[ArgNode()]
ARGS_NONE: list =

Undocumented

Value
[]
ARGS_ONE_FILTER =

Undocumented

Value
[ArgFilter(min=1, max=1)]
ARGS_ONE_GROUP =

Undocumented

Value
[ArgGroup(min=1, max=1)]
ARGS_ONE_INSTANCE =

Undocumented

Value
[ArgInstance(min=1, max=1)]
ARGS_ONE_NETWORK =

Undocumented

Value
[ArgNetwork(min=1, max=1)]
ARGS_ONE_NODE =

Undocumented

Value
[ArgNode(min=1, max=1)]
ARGS_ONE_OS =

Undocumented

Value
[ArgOs(min=1, max=1)]
QR_INCOMPLETE =

Undocumented

QR_NORMAL =

Undocumented

QR_UNKNOWN =

Undocumented

def _CheckArguments(cmd, args_def, args):

Verifies the arguments using the argument definition.

Algorithm:

  1. Abort with error if values specified by user but none expected.
  1. For each argument in definition

    1. Keep running count of minimum number of values (min_count)
    1. Keep running count of maximum number of values (max_count)
    1. If it has an unlimited number of values
      1. Abort with error if it's not the last argument in the definition
  1. If last argument has limited number of values
    1. Abort with error if number of values doesn't match or is too large
  1. Abort with error if user didn't pass enough values (min_count)
def _ExtendTags(opts, args):

Extend the args if a source file has been given.

This function will extend the tags with the contents of the file passed in the 'tags_source' attribute of the opts parameter. A file named '-' will be replaced by stdin.

def _ExtractTagsObject(opts, args):

Extract the tag type object.

Note that this function will modify its args parameter.

def _FieldDescValues(fdef):

Helper function for GenericListFields to get query field description.

Parameters
fdef:objects.QueryFieldDefinitionUndocumented
Returns
listUndocumented
def _FormatBool(value):

Formats a boolean value as a string.

def _FormatListInfoDefault(data, def_data):

Undocumented

def _FormatUsage(binary, commands):

Generates a nice description of all commands.

Parameters
binaryScript name
commandsDictionary containing command definitions
def _GetAlignmentMapping(data):

Returns info about alignment if present in an encoded ordered dictionary.

Parameters
data:list of tupleThe encoded ordered dictionary, as defined in _SerializeGenericInfo.
Returns
dict of any to intThe dictionary mapping alignment groups to the maximum length of the dictionary key found in the group.
def _GetColFormatString(width, align_right):

Returns the format string for a field.

def _GetColumnFormatter(fdef, override, unit):

Returns formatting function for a field.

Parameters
fdef:objects.QueryFieldDefinitionUndocumented
override:dictDictionary for overriding field formatting functions, indexed by field name, contents like _DEFAULT_FORMAT_QUERY
unit:stringUnit used for formatting fields of type constants.QFT_UNIT
Returns
tuple; (callable, bool)Returns the function to format a value (takes one parameter) and a boolean for aligning the value on the right-hand side
def _GetISpecsInAllowedValues(minmax_ispecs, allowed_values):

Undocumented

def _GetUnknownFields(fdefs):

Returns list of unknown fields included in fdefs.

Parameters
fdefs:list of objects.QueryFieldDefinitionUndocumented
def _InitISpecsFromFullOpts(ipolicy_out, minmax_ispecs, std_ispecs, group_ipolicy, allowed_values):

Undocumented

def _InitISpecsFromSplitOpts(ipolicy, ispecs_mem_size, ispecs_cpu_count, ispecs_disk_count, ispecs_disk_size, ispecs_nic_count, group_ipolicy, fill_all):

Undocumented

def _InitReasonTrail(op, opts):

Builds the first part of the reason trail

Builds the initial part of the reason trail, adding the user provided reason (if it exists) and the name of the command starting the operation.

Parameters
opthe opcode the reason trail will be added to
optsthe command line options selected by the user
def _MaybeParseUnit(elements):

Parses and returns an array of potential values with units.

def _NotAContainer(data):

Checks whether the input is not a container data type.

Returns
boolUndocumented
def _ParseArgs(binary, argv, commands, aliases, env_override):

Parser for the command line arguments.

This function parses the arguments and returns the function which must be executed together with its (modified) arguments.

Parameters
binaryScript name
argvCommand line arguments
commandsDictionary containing command definitions
aliasesdictionary with command aliases {"alias": "target", ...}
env_overridelist of env variables allowed for default args
Raises
_ShowUsageIf usage description should be shown
_ShowVersionIf version should be shown
def _ParseISpec(spec, keyname, required):

Undocumented

def _ParseSpecUnit(spec, keyname):

Undocumented

def _PrintSpecsParameters(buf, specs):

Undocumented

def _SerializeGenericInfo(buf, data, level, afterkey=False):

Formatting core of PrintGenericInfo.

Parameters
buf(string) stream to accumulate the result into
datadata to format
level:intdepth in the data hierarchy, used for indenting
afterkey:boolTrue when we are in the middle of a line after a key (used to properly add newlines or indentation)
def _ToStream(stream, txt, *args):

Write a message to a stream, bypassing the logging system

Parameters
stream:file objectthe file to which we should write
txt:strthe message
*argsUndocumented
def _WarnUnknownFields(fdefs):

Prints a warning to stderr if a query included unknown fields.

Parameters
fdefs:list of objects.QueryFieldDefinitionUndocumented
_CHOOSE_BATCH: int =

Undocumented

Value
25
_DEFAULT_FORMAT_QUERY =

Undocumented

Value
{constants.QFT_TEXT: (str, False),
 constants.QFT_BOOL: (_FormatBool, False),
 constants.QFT_NUMBER: (str, True),
 constants.QFT_NUMBER_FLOAT: (str, True),
 constants.QFT_TIMESTAMP: (utils.FormatTime, False),
 constants.QFT_OTHER: (str, False),
 constants.QFT_UNKNOWN: (str, False)}
_QFT_NAMES =

Undocumented

Value
{constants.QFT_UNKNOWN: 'Unknown',
 constants.QFT_TEXT: 'Text',
 constants.QFT_BOOL: 'Boolean',
 constants.QFT_NUMBER: 'Number',
 constants.QFT_NUMBER_FLOAT: 'Floating-point number',
 constants.QFT_UNIT: 'Storage size',
 constants.QFT_TIMESTAMP: 'Timestamp',
...