当前位置: 首页>>代码示例>>Python>>正文


Python gflags.FlagsError方法代码示例

本文整理汇总了Python中gflags.FlagsError方法的典型用法代码示例。如果您正苦于以下问题:Python gflags.FlagsError方法的具体用法?Python gflags.FlagsError怎么用?Python gflags.FlagsError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gflags的用法示例。


在下文中一共展示了gflags.FlagsError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_flags

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def process_flags(flags=[]):
    """Uses the command-line flags to set the logging level.

    Args:
    argv: List of command line arguments passed to the python script.
    """

    # Let the gflags module process the command-line arguments.
    try:
        FLAGS(flags)
    except gflags.FlagsError as e:
        print('%s\nUsage: %s ARGS\n%s' % (e, str(flags), FLAGS))
        sys.exit(1)

    # Set the logging according to the command-line flag.
    logging.getLogger().setLevel(getattr(logging, FLAGS.logging_level)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:auth.py

示例2: InstallExceptionHandler

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def InstallExceptionHandler(handler):
  """Install an exception handler.

  Args:
    handler: an object conforming to the interface defined in ExceptionHandler

  Raises:
    TypeError: handler was not of the correct type

  All installed exception handlers will be called if main() exits via
  an abnormal exception, i.e. not one of SystemExit, KeyboardInterrupt,
  FlagsError or UsageError.
  """
  if not isinstance(handler, ExceptionHandler):
    raise TypeError('handler of type %s does not inherit from ExceptionHandler'
                    % type(handler))
  EXCEPTION_HANDLERS.append(handler) 
开发者ID:google,项目名称:google-apputils,代码行数:19,代码来源:app.py

示例3: ParseFlagsWithUsage

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def ParseFlagsWithUsage(argv):
  """Parse the flags, exiting (after printing usage) if they are unparseable.

  Args:
    argv: command line arguments

  Returns:
    remaining command line arguments after parsing flags
  """
  # Update the global commands.
  # pylint: disable=global-statement
  global _cmd_argv
  try:
    _cmd_argv = FLAGS(argv)
    return _cmd_argv
  except flags.FlagsError, error:
    ShortHelpAndExit('FATAL Flags parsing error: %s' % error) 
开发者ID:google,项目名称:google-apputils,代码行数:19,代码来源:appcommands.py

示例4: main

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def main():
  try:
    gflags.FLAGS(sys.argv)
  except gflags.FlagsError as e:
    print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], gflags.FLAGS)
    sys.exit(1)
  logging.basicConfig(level=logging.INFO)

  if gflags.FLAGS.mindmap_file is None:
    print 'Usage: %s ARGS\n%s' % (sys.argv[0], gflags.FLAGS)
    sys.exit(1)

  org = Organization(
    codecs.open(gflags.FLAGS.mindmap_file, 'r', 'utf8').read())
  if gflags.FLAGS.html_file is not None:
    org.OutputToHTML(gflags.FLAGS.html_file)

  if gflags.FLAGS.beamer_latex_file is not None:
    org.OutputToBeamerLatex(gflags.FLAGS.beamer_latex_file)

  if gflags.FLAGS.latex_file is not None:
    org.OutputToLatex(gflags.FLAGS.latex_file) 
开发者ID:xuehuichao,项目名称:freemind-latex,代码行数:24,代码来源:convert_lib.py

示例5: main

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def main(argv):
    # Utility main to load flags
    try:
      argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError:
      print ('Usage: %s ARGS\\n%s' % (sys.argv[0], FLAGS))

      sys.exit(1)
    _main() 
开发者ID:uzh-rpg,项目名称:rpg_public_dronet,代码行数:11,代码来源:plot_results.py

示例6: main

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def main(argv):
    # Utility main to load flags
    try:
      argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError:
      print ('Usage: %s ARGS\\n%s' % (sys.argv[0], FLAGS))
      sys.exit(1)
    _main() 
开发者ID:uzh-rpg,项目名称:rpg_public_dronet,代码行数:10,代码来源:evaluation.py

示例7: parse_flags_with_usage

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def parse_flags_with_usage(args):
  """Try parsing the flags, printing usage and exiting if unparseable."""
  try:
    argv = FLAGS(args)
    return argv
  except flags.FlagsError, error:
    sys.stderr.write('FATAL Flags parsing error: %s\n' % error)
    sys.stderr.write('Pass --helpshort or --helpfull to see help on flags.\n')
    sys.exit(1) 
开发者ID:google,项目名称:google-apputils,代码行数:11,代码来源:app.py

示例8: prepare_flags

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def prepare_flags(argv):
    '''Set up flags. Returns true if the flag settings are acceptable.'''
    try:
        argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError, e:
        return False 
开发者ID:wetchler,项目名称:okcupid,代码行数:8,代码来源:FetchProfiles.py

示例9: prepare_flags

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def prepare_flags(argv):
    '''Set up flags. Returns true if the flag settings are acceptable.'''
    try:
        argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError, e:
        print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS)
        return False 
开发者ID:wetchler,项目名称:okcupid,代码行数:9,代码来源:FindUsers.py

示例10: main

# 需要导入模块: import gflags [as 别名]
# 或者: from gflags import FlagsError [as 别名]
def main(argv):
    # Utility main to load flags
    try:
      argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError:
      print ('Usage: %s ARGS\\n%s' % (sys.argv[0], FLAGS))
      sys.exit(1)
    _test_masks() 
开发者ID:antonilo,项目名称:unsupervised_detection,代码行数:10,代码来源:test_generator_ensemble.py


注:本文中的gflags.FlagsError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。