Guest User

Untitled

a guest
Apr 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3.  
  4. # import modules used here -- sys is a very standard one
  5. import sys, argparse, logging
  6.  
  7. # Gather our code in a main() function
  8. def main(args, loglevel):
  9. logging.basicConfig(format="%(levelname)s: %(message)s", level=loglevel)
  10.  
  11. # TODO Replace this with your actual code.
  12. print ("Hello there.")
  13. logging.info("You passed an argument.")
  14. logging.debug("Your Argument: %s" % args.argument)
  15.  
  16. # Standard boilerplate to call the main() function to begin
  17. # the program.
  18. if __name__ == '__main__':
  19. parser = argparse.ArgumentParser(
  20. description = "Does a thing to some stuff.",
  21. epilog = "As an alternative to the commandline, params can be placed in a file, one per line, and specified on the commandline like '%(prog)s @params.conf'.",
  22. fromfile_prefix_chars = '@' )
  23. # TODO Specify your real parameters here.
  24. parser.add_argument(
  25. "argument",
  26. help = "pass ARG to the program",
  27. metavar = "ARG")
  28. parser.add_argument(
  29. "-v",
  30. "--verbose",
  31. help="increase output verbosity",
  32. action="store_true",
  33. default = True)
  34. args = parser.parse_args()
  35.  
  36. # Setup logging
  37. if args.verbose:
  38. loglevel = logging.DEBUG
  39. else:
  40. loglevel = logging.INFO
  41.  
  42. main(args, loglevel)
Add Comment
Please, Sign In to add comment