daily pastebin goal
31%
SHARE
TWEET

timeboxer

a guest Feb 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top