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'
|
__title__ = 'wakatime'
|
||||||
__description__ = 'Common interface to the WakaTime api.'
|
__description__ = 'Common interface to the WakaTime api.'
|
||||||
__url__ = 'https://github.com/wakatime/wakatime'
|
__url__ = 'https://github.com/wakatime/wakatime'
|
||||||
__version_info__ = ('10', '9', '0')
|
__version_info__ = ('11', '0', '0')
|
||||||
__version__ = '.'.join(__version_info__)
|
__version__ = '.'.join(__version_info__)
|
||||||
__author__ = 'Alan Hamlett'
|
__author__ = 'Alan Hamlett'
|
||||||
__author_email__ = 'alan@wakatime.com'
|
__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
|
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.
|
"""Get coding time from WakaTime API for given time range.
|
||||||
|
|
||||||
Returns total time as string or `None` when unable to fetch summary from
|
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
|
ssl_verify = args.ssl_certs_file
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'start': start,
|
'start': 'today',
|
||||||
'end': end,
|
'end': 'today',
|
||||||
}
|
}
|
||||||
|
|
||||||
# send request to api
|
# send request to api
|
||||||
|
@ -219,7 +219,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
||||||
verify=ssl_verify)
|
verify=ssl_verify)
|
||||||
except RequestException:
|
except RequestException:
|
||||||
if should_try_ntlm:
|
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()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -228,12 +228,12 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
||||||
'traceback': traceback.format_exc(),
|
'traceback': traceback.format_exc(),
|
||||||
}
|
}
|
||||||
log.error(exception_data)
|
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
|
return None, API_ERROR
|
||||||
|
|
||||||
except: # delete cached session when requests raises unknown exception
|
except: # delete cached session when requests raises unknown exception
|
||||||
if should_try_ntlm:
|
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()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -242,7 +242,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
||||||
'traceback': traceback.format_exc(),
|
'traceback': traceback.format_exc(),
|
||||||
}
|
}
|
||||||
log.error(exception_data)
|
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
|
return None, API_ERROR
|
||||||
|
|
||||||
code = response.status_code if response is not None else None
|
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(),
|
'traceback': traceback.format_exc(),
|
||||||
}
|
}
|
||||||
log.error(exception_data)
|
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
|
return None, API_ERROR
|
||||||
else:
|
else:
|
||||||
if should_try_ntlm:
|
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()
|
session_cache.delete()
|
||||||
log.debug({
|
log.debug({
|
||||||
|
@ -272,7 +272,7 @@ def get_coding_time(start, end, args, use_ntlm_proxy=False):
|
||||||
'response_text': content,
|
'response_text': content,
|
||||||
})
|
})
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
return 'Error: {}'.format(code), API_ERROR
|
return 'Error: {0}'.format(code), API_ERROR
|
||||||
return None, API_ERROR
|
return None, API_ERROR
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ def parse_arguments():
|
||||||
'online 5 offline heartbeats are synced. Can ' +
|
'online 5 offline heartbeats are synced. Can ' +
|
||||||
'be used without --entity to only sync offline ' +
|
'be used without --entity to only sync offline ' +
|
||||||
'activity without generating new heartbeats.')
|
'activity without generating new heartbeats.')
|
||||||
parser.add_argument('--show-time-today', dest='show_time_today',
|
parser.add_argument('--today', dest='today',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Prints dashboard time for Today, then exits.')
|
help='Prints dashboard time for Today, then exits.')
|
||||||
parser.add_argument('--config', dest='config', action=StoreWithoutQuotes,
|
parser.add_argument('--config', dest='config', action=StoreWithoutQuotes,
|
||||||
|
@ -248,7 +248,7 @@ def parse_arguments():
|
||||||
if not args.entity:
|
if not args.entity:
|
||||||
if args.file:
|
if args.file:
|
||||||
args.entity = 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')
|
parser.error('argument --entity is required')
|
||||||
|
|
||||||
if not args.sync_offline_activity:
|
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'))
|
sys.path.insert(0, os.path.join(pwd, 'packages'))
|
||||||
|
|
||||||
from .__about__ import __version__
|
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 .arguments import parse_arguments
|
||||||
from .compat import u, json
|
from .compat import u, json
|
||||||
from .constants import SUCCESS, UNKNOWN_ERROR, HEARTBEATS_PER_REQUEST
|
from .constants import SUCCESS, UNKNOWN_ERROR, HEARTBEATS_PER_REQUEST
|
||||||
|
@ -42,8 +42,8 @@ def execute(argv=None):
|
||||||
|
|
||||||
setup_logging(args, __version__)
|
setup_logging(args, __version__)
|
||||||
|
|
||||||
if args.show_time_today:
|
if args.today:
|
||||||
text, retval = get_coding_time('today', 'today', args)
|
text, retval = get_time_today(args)
|
||||||
if text:
|
if text:
|
||||||
print(text)
|
print(text)
|
||||||
return retval
|
return retval
|
||||||
|
|
Loading…
Reference in a new issue