daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. __author__ = "Rob Knight, Gavin Huttley, and Peter Maxwell"
  3. __copyright__ = "Copyright 2007, The Cogent Project"
  4. __credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley",
  5.                    "Matthew Wakefield"]
  6. __license__ = "GPL"
  7. __version__ = "1.0.1"
  8. __maintainer__ = "Rob Knight"
  9. __email__ = "rob@spot.colorado.edu"
  10. __status__ = "Production"
  11. """
  12.  
  13. import sys
  14. import argparse
  15. import logging
  16.  
  17.  
  18. module = sys.modules['__main__'].__file__
  19. log = logging.getLogger(module)
  20.  
  21.  
  22. def parse_command_line(argv):
  23.     """Parse command line argument. See -h option
  24.  
  25.    :param argv: arguments on the command line must include caller file name.
  26.    """
  27.     formatter_class = argparse.RawDescriptionHelpFormatter
  28.     parser = argparse.ArgumentParser(description=module,
  29.                                      formatter_class=formatter_class)
  30.     parser.add_argument("--version", action="version",
  31.                         version="%(prog)s {}".format(__version__))
  32.     parser.add_argument("-v", "--verbose", dest="verbose_count",
  33.                         action="count", default=0,
  34.                         help="increases log verbosity for each occurence.")
  35.     parser.add_argument('-o', metavar="output",
  36.                         type=argparse.FileType('w'), default=sys.stdout,
  37.                         help="redirect output to a file")
  38.     parser.add_argument('input', metavar="input", nargs='+',
  39.                         argparse.REMAINDER, help="input if any...")
  40.     arguments = parser.parse_args(argv[1:])
  41.     # Sets log level to WARN going more verbose for each new -v.
  42.     log.setLevel(max(3 - arguments.verbose_count, 0) * 10)
  43.     return arguments
  44.  
  45.  
  46. def main(args):
  47.     """main function to [...]
  48.    
  49.    launch AD tests
  50.    launch LDAP tests
  51.    [...]
  52.    
  53.    Arguments:
  54.        args {list} -- command line arguments
  55.    """
  56.     deleteUserApp("AD")
  57.     # [...]
  58.  
  59.  
  60. if __name__ == "__main__":
  61.     logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
  62.                         format='%(name)s (%(levelname)s): %(message)s')
  63.     try:
  64.         args = parse_command_line(sys.argv)
  65.         main(args)
  66.     except KeyboardInterrupt:
  67.         log.error('Program interrupted!')
  68.     finally:
  69.         logging.shutdown()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top