From 685aee755643789f4865371903d4afeec82ae19d Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 7 May 2019 18:38:47 -0700 Subject: [PATCH] upgrade wakatime-cli to v11.0.0 --- packages/wakatime/__about__.py | 2 +- packages/wakatime/api.py | 20 ++++++++++---------- packages/wakatime/arguments.py | 4 ++-- packages/wakatime/main.py | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/wakatime/__about__.py b/packages/wakatime/__about__.py index 0a6b9ae..1dbd215 100644 --- a/packages/wakatime/__about__.py +++ b/packages/wakatime/__about__.py @@ -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' diff --git a/packages/wakatime/api.py b/packages/wakatime/api.py index 4665ccc..16286a4 100644 --- a/packages/wakatime/api.py +++ b/packages/wakatime/api.py @@ -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 diff --git a/packages/wakatime/arguments.py b/packages/wakatime/arguments.py index 1e41c98..035127d 100644 --- a/packages/wakatime/arguments.py +++ b/packages/wakatime/arguments.py @@ -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: diff --git a/packages/wakatime/main.py b/packages/wakatime/main.py index c169eb4..02a40dc 100644 --- a/packages/wakatime/main.py +++ b/packages/wakatime/main.py @@ -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