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.

76 lines
3.0 KiB

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