be fully backwards-compatible by renaming ~/.wakatime to ~/.wakatime.conf

This commit is contained in:
Alan Hamlett 2013-07-08 17:08:13 -07:00
parent b5b76ffb1f
commit 8d6397b8b2
1 changed files with 15 additions and 4 deletions

View File

@ -9,7 +9,7 @@ __version__ = '0.2.1'
import time import time
import uuid import uuid
from os.path import expanduser, dirname, realpath from os.path import expanduser, dirname, realpath, isfile
from subprocess import call, Popen from subprocess import call, Popen
import sublime import sublime
@ -25,6 +25,14 @@ API_CLIENT = '%s/packages/wakatime/wakatime.py' % PLUGIN_DIR
LAST_ACTION = 0 LAST_ACTION = 0
LAST_FILE = None LAST_FILE = None
# To be backwards compatible, rename config file
if isfile(expanduser('~/.wakatime')):
call([
'mv',
expanduser('~/.wakatime'),
expanduser('~/.wakatime.conf')
])
def api(targetFile, timestamp, isWrite=False, endtime=None): def api(targetFile, timestamp, isWrite=False, endtime=None):
global LAST_ACTION, LAST_FILE global LAST_ACTION, LAST_FILE
@ -54,19 +62,22 @@ def away(now):
if duration > AWAY_MINUTES * 60: if duration > AWAY_MINUTES * 60:
duration = int(duration) duration = int(duration)
units = 'seconds' units = 'seconds'
if duration > 60: if duration > 59:
duration = int(duration / 60.0) duration = int(duration / 60.0)
units = 'minutes' units = 'minutes'
if duration > 60: if duration > 59:
duration = int(duration / 60.0) duration = int(duration / 60.0)
units = 'hours' units = 'hours'
if duration > 24:
duration = int(duration / 24.0)
units = 'days'
return sublime\ return sublime\
.ok_cancel_dialog("You were away %d %s. Add time to current file?"\ .ok_cancel_dialog("You were away %d %s. Add time to current file?"\
% (duration, units), 'Yes, log this time') % (duration, units), 'Yes, log this time')
def enough_time_passed(now): def enough_time_passed(now):
return (now - LAST_ACTION >= 5 * 60) return (now - LAST_ACTION >= 299)
class WakatimeListener(sublime_plugin.EventListener): class WakatimeListener(sublime_plugin.EventListener):