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.

72 lines
2.9 KiB

10 years ago
  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. desc = "Example application to show Gooey's various widgets"
  17. file_help_msg = "Name of the file you want to process"
  18. my_cool_parser = GooeyParser(description=desc)
  19. my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional
  20. my_cool_parser.add_argument("directory", help="Directory to store output") # positional
  21. my_cool_parser.add_argument('-c', '--countdown', default=2, type=int, help='sets the time to count down from you see its quite simple!')
  22. my_cool_parser.add_argument('-j', '--cron-schedule', type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
  23. my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
  24. my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
  25. my_cool_parser.add_argument('-v', '--verbose', action='count')
  26. my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
  27. my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
  28. my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
  29. my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
  30. verbosity = my_cool_parser.add_mutually_exclusive_group()
  31. verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
  32. verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
  33. print my_cool_parser._actions
  34. print 'inside of main(), my_cool_parser =', my_cool_parser
  35. args = my_cool_parser.parse_args()
  36. print 'EHOOOOOOOOOOOO'
  37. print sys.argv
  38. print args.countdown
  39. print args.showtime
  40. start_time = _time()
  41. print 'Counting down from %s' % args.countdown
  42. while _time() - start_time < args.countdown:
  43. if args.showtime:
  44. print 'printing message at: %s' % _time()
  45. else:
  46. print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
  47. _sleep(.5)
  48. print 'Finished running the program. Byeeeeesss!'
  49. raise ValueError("Something has gone wrong! AHHHHHHHHHHH")
  50. def here_is_smore():
  51. pass
  52. if __name__ == '__main__':
  53. print sys.argv
  54. main()
  55. # import inspect
  56. # import dis
  57. # # print dir(main.__code__)
  58. # # for i in dir(main.__code__):
  59. # # print i, getattr(main.__code__, i)
  60. # print dis.dis(main.__code__)
  61. # # for i in inspect.getmembers(main):
  62. # # print i