Advertisement
Guest User

timeboxer

a guest
Feb 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import logging
  4. import sys
  5. import datetime, time
  6.  
  7. today_pretty = datetime.date.today().strftime("%Y-%m-%d.log")
  8. logging.basicConfig(filename="/home/username/notes/focus_logs/%s" % today_pretty,
  9.                     format="%(asctime)s %(message)s",
  10.                     level=logging.INFO,
  11.                     datefmt="%H:%M:%S")
  12.  
  13. if __name__ == "__main__":
  14.     if len(sys.argv) < 3:
  15.         print "usage: focus.py <duration> \"<message>\""
  16.     else:
  17.             logging.info("focusing %sm %r" % (sys.argv[1], sys.argv[2]))
  18.             try:
  19.                 time.sleep(60 * int(sys.argv[1]))
  20.             except KeyboardInterrupt:
  21.                 logging.info("interrupted")
  22.                 sys.exit(0)
  23.             try:
  24.                 while True:
  25.                     sys.stdout.write("\a")
  26.                     sys.stdout.flush()
  27.                     time.sleep(0.5)
  28.                     sys.stdout.write("\a")
  29.                     sys.stdout.flush()
  30.                     time.sleep(0.5)
  31.                     sys.stdout.write("\a")
  32.                     sys.stdout.flush()
  33.                     time.sleep(2)
  34.             except KeyboardInterrupt:
  35.                 logging.info("finished")
  36.                 sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement