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.

66 lines
2.8 KiB

10 years ago
10 years ago
10 years ago
10 years ago
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
  8. from time import sleep as _sleep
  9. from gooey import Gooey
  10. from gooey import GooeyParser
  11. @Gooey
  12. def arbitrary_function():
  13. desc = "Example application to show Gooey's various widgets"
  14. file_help_msg = "Name of the file you want to process"
  15. my_cool_parser = GooeyParser(description=desc)
  16. my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser") # positional
  17. my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser") # positional
  18. my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver") # positional
  19. my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser") # 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. main(args)
  37. def main(args):
  38. print sys.argv
  39. print args.countdown
  40. print args.showtime
  41. start_time = _time()
  42. print 'Counting down from %s' % args.countdown
  43. while _time() - start_time < args.countdown:
  44. if args.showtime:
  45. print 'printing message at: %s' % _time()
  46. else:
  47. print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
  48. _sleep(.5)
  49. print 'Finished running the program. Byeeeeesss!'
  50. def here_is_smore():
  51. pass
  52. if __name__ == '__main__':
  53. arbitrary_function()