Python gflags.FlagsError() Examples

The following are 14 code examples of gflags.FlagsError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gflags , or try the search function .
Example #1
Source File: auth.py    From Computable with MIT License 6 votes vote down vote up
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)) 
Example #2
Source File: app.py    From google-apputils with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: appcommands.py    From google-apputils with Apache License 2.0 6 votes vote down vote up
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) 
Example #4
Source File: convert_lib.py    From freemind-latex with Apache License 2.0 6 votes vote down vote up
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) 
Example #5
Source File: plot_results.py    From rpg_public_dronet with MIT License 5 votes vote down vote up
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() 
Example #6
Source File: evaluation.py    From rpg_public_dronet with MIT License 5 votes vote down vote up
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() 
Example #7
Source File: plot_loss.py    From rpg_public_dronet with MIT License 5 votes vote down vote up
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() 
Example #8
Source File: cnn.py    From rpg_public_dronet with MIT License 5 votes vote down vote up
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() 
Example #9
Source File: app.py    From google-apputils with Apache License 2.0 5 votes vote down vote up
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) 
Example #10
Source File: FetchProfiles.py    From okcupid with MIT License 5 votes vote down vote up
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 
Example #11
Source File: FindUsers.py    From okcupid with MIT License 5 votes vote down vote up
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 
Example #12
Source File: test_generator_ensemble.py    From unsupervised_detection with MIT License 5 votes vote down vote up
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() 
Example #13
Source File: test_generator.py    From unsupervised_detection with MIT License 5 votes vote down vote up
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() 
Example #14
Source File: train.py    From unsupervised_detection with MIT License 5 votes vote down vote up
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()