forked from luna/vim-rana-local
upgrade wakatime-cli to v11.0.0
This commit is contained in:
parent
6c21f85332
commit
685aee7556
4 changed files with 16 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
__title__ = 'wakatime'
|
||||
__description__ = 'Common interface to the WakaTime api.'
|
||||
__url__ = 'https://github.com/wakatime/wakatime'
|
||||
__version_info__ = ('10', '9', '0')
|
||||
__version_info__ = ('11', '0', '0')
|
||||
__version__ = '.'.join(__version_info__)
|
||||
__author__ = 'Alan Hamlett'
|
||||
__author_email__ = 'alan@wakatime.com'
|
||||
|
|
|
@ -163,7 +163,7 @@ def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
|||
return AUTH_ERROR if code == 401 else API_ERROR
|
||||
|
||||
|
||||
def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
||||
def get_time_today(args, use_ntlm_proxy=False):
|
||||
"""Get coding time from WakaTime API for given time range.
|
||||
|
||||
Returns total time as string or `None` when unable to fetch summary from
|
||||
|
@ -207,8 +207,8 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
ssl_verify = args.ssl_certs_file
|
||||
|
||||
params = {
|
||||
'start': start,
|
||||
'end': end,
|
||||
'start': 'today',
|
||||
'end': 'today',
|
||||
}
|
||||
|
||||
# send request to api
|
||||
|
@ -219,7 +219,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
verify=ssl_verify)
|
||||
except RequestException:
|
||||
if should_try_ntlm:
|
||||
return get_coding_time(start, end, args, use_ntlm_proxy=True)
|
||||
return get_time_today(args, use_ntlm_proxy=True)
|
||||
|
||||
session_cache.delete()
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
|
@ -228,12 +228,12 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
'traceback': traceback.format_exc(),
|
||||
}
|
||||
log.error(exception_data)
|
||||
return '{}: {}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return '{0}: {1}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return None, API_ERROR
|
||||
|
||||
except: # delete cached session when requests raises unknown exception
|
||||
if should_try_ntlm:
|
||||
return get_coding_time(start, end, args, use_ntlm_proxy=True)
|
||||
return get_time_today(args, use_ntlm_proxy=True)
|
||||
|
||||
session_cache.delete()
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
|
@ -242,7 +242,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
'traceback': traceback.format_exc(),
|
||||
}
|
||||
log.error(exception_data)
|
||||
return '{}: {}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return '{0}: {1}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return None, API_ERROR
|
||||
|
||||
code = response.status_code if response is not None else None
|
||||
|
@ -260,11 +260,11 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
'traceback': traceback.format_exc(),
|
||||
}
|
||||
log.error(exception_data)
|
||||
return '{}: {}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return '{0}: {1}'.format(sys.exc_info()[0].__name__, u(sys.exc_info()[1])), API_ERROR
|
||||
return None, API_ERROR
|
||||
else:
|
||||
if should_try_ntlm:
|
||||
return get_coding_time(start, end, args, use_ntlm_proxy=True)
|
||||
return get_time_today(args, use_ntlm_proxy=True)
|
||||
|
||||
session_cache.delete()
|
||||
log.debug({
|
||||
|
@ -272,7 +272,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
|||
'response_text': content,
|
||||
})
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
return 'Error: {}'.format(code), API_ERROR
|
||||
return 'Error: {0}'.format(code), API_ERROR
|
||||
return None, API_ERROR
|
||||
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ def parse_arguments():
|
|||
'online 5 offline heartbeats are synced. Can ' +
|
||||
'be used without --entity to only sync offline ' +
|
||||
'activity without generating new heartbeats.')
|
||||
parser.add_argument('--show-time-today', dest='show_time_today',
|
||||
parser.add_argument('--today', dest='today',
|
||||
action='store_true',
|
||||
help='Prints dashboard time for Today, then exits.')
|
||||
parser.add_argument('--config', dest='config', action=StoreWithoutQuotes,
|
||||
|
@ -248,7 +248,7 @@ def parse_arguments():
|
|||
if not args.entity:
|
||||
if args.file:
|
||||
args.entity = args.file
|
||||
elif (not args.sync_offline_activity or args.sync_offline_activity == 'none') and not args.show_time_today:
|
||||
elif (not args.sync_offline_activity or args.sync_offline_activity == 'none') and not args.today:
|
||||
parser.error('argument --entity is required')
|
||||
|
||||
if not args.sync_offline_activity:
|
||||
|
|
|
@ -22,7 +22,7 @@ sys.path.insert(0, os.path.dirname(pwd))
|
|||
sys.path.insert(0, os.path.join(pwd, 'packages'))
|
||||
|
||||
from .__about__ import __version__
|
||||
from .api import send_heartbeats, get_coding_time
|
||||
from .api import send_heartbeats, get_time_today
|
||||
from .arguments import parse_arguments
|
||||
from .compat import u, json
|
||||
from .constants import SUCCESS, UNKNOWN_ERROR, HEARTBEATS_PER_REQUEST
|
||||
|
@ -42,8 +42,8 @@ def execute(argv=None):
|
|||
|
||||
setup_logging(args, __version__)
|
||||
|
||||
if args.show_time_today:
|
||||
text, retval = get_coding_time('today', 'today', args)
|
||||
if args.today:
|
||||
text, retval = get_time_today(args)
|
||||
if text:
|
||||
print(text)
|
||||
return retval
|
||||
|
|
Loading…
Reference in a new issue