You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.0 KiB

  1. '''
  2. Created on Dec 21, 2013
  3. @author: Chris
  4. '''
  5. import sys
  6. import hashlib
  7. from time import time as _time, time
  8. from time import sleep as _sleep
  9. # from argparse import ArgumentParser
  10. # import argparse
  11. import argparse as ap
  12. from argparse import ArgumentParser as AP
  13. from gooey import Gooey
  14. from gooey import GooeyParser
  15. def main():
  16. '''
  17. does stuff with parser.parse_args()
  18. '''
  19. desc = "Mock application to test Gooey's functionality"
  20. file_help_msg = "Name of the file you want to process"
  21. my_cool_parser = GooeyParser(description=desc)
  22. my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional
  23. my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output") # positional
  24. my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser')
  25. # my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  26. my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  27. my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  28. my_cool_parser.add_argument('-v', '--verbose', action='count')
  29. my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  30. my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  31. my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  32. my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  33. verbosity = my_cool_parser.add_mutually_exclusive_group()
  34. verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  35. verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  36. print my_cool_parser._actions
  37. print 'inside of main(), my_cool_parser =', my_cool_parser
  38. args = my_cool_parser.parse_args()
  39. print sys.argv
  40. print args.countdown
  41. print args.showtime
  42. start_time = _time()
  43. print 'Counting down from %s' % args.countdown
  44. while _time() - start_time < args.countdown:
  45. if args.showtime:
  46. print 'printing message at: %s' % _time()
  47. else:
  48. print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
  49. _sleep(.5)
  50. print 'Finished running the program. Byeeeeesss!'
  51. raise ValueError("Something has gone wrong! AHHHHHHHHHHH")
  52. def here_is_smore():
  53. pass
  54. if __name__ == '__main__':
  55. print sys.argv
  56. main()
  57. # import inspect
  58. # import dis
  59. # # print dir(main.__code__)
  60. # # for i in dir(main.__code__):
  61. # # print i, getattr(main.__code__, i)
  62. # print dis.dis(main.__code__)
  63. # # for i in inspect.getmembers(main):
  64. # # print i