當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。