Skip to content

Instantly share code, notes, and snippets.

@mygeekdaddy
Created July 26, 2014 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mygeekdaddy/1b68fa011f89a139a833 to your computer and use it in GitHub Desktop.
Save mygeekdaddy/1b68fa011f89a139a833 to your computer and use it in GitHub Desktop.
stopTimer.py script for WorkLog workflow
# stopTimer.py - generates closure notes for Drafts action
# & removes the temporary 'timer.txt' file
# by: Jason Verly
# rev date: 2014-07-25
import time
import console
import os
import os.path
import webbrowser
import clipboard
import urllib
if os.path.isfile('timer.txt'):
console.clear()
f = open('timer.txt', 'r+')
s = f.read()
a=float(s)
curDate = time.time()
diffDate = str(round((curDate - a)/60))
endDate = time.strftime('%Y-%m-%d %I:%M %p', time.localtime(curDate))
text = 'Task stopped at ' + endDate + '\n' + 'Total task duration: ' + diffDate + '\n————————————————————'
clipboard.set(text)
encodetxt = urllib.quote(text, safe='')
draft_url = 'drafts://x-callback-url/create?text='
action = '&action=WorkLog%20Closure'
os.remove('timer.txt')
webbrowser.open(draft_url + encodetxt + action)
else:
console.clear()
console.hud_alert('Timer not started', 'error')
webbrowser.open('drafts://')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment