upgrade wakatime-cli to v10.8.2

This commit is contained in:
Alan Hamlett 2019-03-30 18:53:40 -07:00
parent 2b6e32b578
commit bf20551849
7 changed files with 37 additions and 6 deletions

View File

@ -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', '6', '1') __version_info__ = ('10', '8', '2')
__version__ = '.'.join(__version_info__) __version__ = '.'.join(__version_info__)
__author__ = 'Alan Hamlett' __author__ = 'Alan Hamlett'
__author_email__ = 'alan@wakatime.com' __author_email__ = 'alan@wakatime.com'

View File

@ -99,12 +99,16 @@ def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
should_try_ntlm = '\\' in args.proxy should_try_ntlm = '\\' in args.proxy
proxies['https'] = args.proxy proxies['https'] = args.proxy
ssl_verify = not args.nosslverify
if args.ssl_certs_file and ssl_verify:
ssl_verify = args.ssl_certs_file
# send request to api # send request to api
response, code = None, None response, code = None, None
try: try:
response = session.post(api_url, data=request_body, headers=headers, response = session.post(api_url, data=request_body, headers=headers,
proxies=proxies, timeout=timeout, proxies=proxies, timeout=timeout,
verify=not args.nosslverify) verify=ssl_verify)
except RequestException: except RequestException:
if should_try_ntlm: if should_try_ntlm:
return send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=True) return send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=True)

View File

@ -103,6 +103,10 @@ def parse_arguments():
help='Disables SSL certificate verification for HTTPS '+ help='Disables SSL certificate verification for HTTPS '+
'requests. By default, SSL certificates are ' + 'requests. By default, SSL certificates are ' +
'verified.') 'verified.')
parser.add_argument('--ssl-certs-file', dest='ssl_certs_file',
action=StoreWithoutQuotes,
help='Override the bundled Python Requests CA certs ' +
'file. By default, uses certifi for ca certs.')
parser.add_argument('--project', dest='project', action=StoreWithoutQuotes, parser.add_argument('--project', dest='project', action=StoreWithoutQuotes,
help='Optional project name.') help='Optional project name.')
parser.add_argument('--alternate-project', dest='alternate_project', parser.add_argument('--alternate-project', dest='alternate_project',
@ -307,6 +311,8 @@ def parse_arguments():
'domain\\user:pass.') 'domain\\user:pass.')
if configs.has_option('settings', 'no_ssl_verify'): if configs.has_option('settings', 'no_ssl_verify'):
args.nosslverify = configs.getboolean('settings', 'no_ssl_verify') args.nosslverify = configs.getboolean('settings', 'no_ssl_verify')
if configs.has_option('settings', 'ssl_certs_file'):
args.ssl_certs_file = configs.get('settings', 'ssl_certs_file')
if not args.verbose and configs.has_option('settings', 'verbose'): if not args.verbose and configs.has_option('settings', 'verbose'):
args.verbose = configs.getboolean('settings', 'verbose') args.verbose = configs.getboolean('settings', 'verbose')
if not args.verbose and configs.has_option('settings', 'debug'): if not args.verbose and configs.has_option('settings', 'debug'):
@ -335,7 +341,7 @@ def boolean_or_list(config_name, args, configs, alternative_names=[]):
"""Get a boolean or list of regexes from args and configs.""" """Get a boolean or list of regexes from args and configs."""
# when argument flag present, set to wildcard regex # when argument flag present, set to wildcard regex
for key in alternative_names: for key in alternative_names + [config_name]:
if hasattr(args, key) and getattr(args, key): if hasattr(args, key) and getattr(args, key):
setattr(args, config_name, ['.*']) setattr(args, config_name, ['.*'])
return return

View File

@ -249,6 +249,9 @@ class Heartbeat(object):
if self.type != 'file': if self.type != 'file':
return return
if not self.entity:
return
if not is_win: if not is_win:
return return

View File

@ -69,6 +69,8 @@ def get_project_info(configs, heartbeat, data):
project_name = data.get('project') or heartbeat.args.project project_name = data.get('project') or heartbeat.args.project
hide_project = heartbeat.should_obfuscate_project() hide_project = heartbeat.should_obfuscate_project()
if hide_project and project_name is not None:
return project_name, None
if project_name is None or branch_name is None: if project_name is None or branch_name is None:

View File

@ -25,6 +25,7 @@ from .packages.pygments.lexers import (
_fn_matches, _fn_matches,
basename, basename,
ClassNotFound, ClassNotFound,
CppLexer,
find_lexer_class, find_lexer_class,
get_lexer_by_name, get_lexer_by_name,
) )
@ -168,6 +169,10 @@ def get_language_from_extension(file_name):
""" """
filepart, extension = os.path.splitext(file_name) filepart, extension = os.path.splitext(file_name)
pathpart, filename = os.path.split(file_name)
if filename == 'go.mod':
return 'Go'
if re.match(r'\.h.*$', extension, re.IGNORECASE) or re.match(r'\.c.*$', extension, re.IGNORECASE): if re.match(r'\.h.*$', extension, re.IGNORECASE) or re.match(r'\.c.*$', extension, re.IGNORECASE):
@ -181,8 +186,12 @@ def get_language_from_extension(file_name):
return 'Objective-C++' return 'Objective-C++'
available_extensions = extensions_in_same_folder(file_name) available_extensions = extensions_in_same_folder(file_name)
if '.cpp' in available_extensions:
return 'C++' for ext in CppLexer.filenames:
ext = ext.lstrip('*')
if ext in available_extensions:
return 'C++'
if '.c' in available_extensions: if '.c' in available_extensions:
return 'C' return 'C'

View File

@ -26,6 +26,7 @@ log = logging.getLogger('WakaTime')
BACKSLASH_REPLACE_PATTERN = re.compile(r'[\\/]+') BACKSLASH_REPLACE_PATTERN = re.compile(r'[\\/]+')
WINDOWS_DRIVE_PATTERN = re.compile(r'^[a-z]:/') WINDOWS_DRIVE_PATTERN = re.compile(r'^[a-z]:/')
WINDOWS_NETWORK_MOUNT_PATTERN = re.compile(r'^\\{2}[a-z]+', re.IGNORECASE)
def should_exclude(entity, include, exclude): def should_exclude(entity, include, exclude):
@ -77,10 +78,16 @@ def format_file_path(filepath):
"""Formats a path as absolute and with the correct platform separator.""" """Formats a path as absolute and with the correct platform separator."""
try: try:
is_windows_network_mount = WINDOWS_NETWORK_MOUNT_PATTERN.match(filepath)
filepath = os.path.realpath(os.path.abspath(filepath)) filepath = os.path.realpath(os.path.abspath(filepath))
filepath = re.sub(BACKSLASH_REPLACE_PATTERN, '/', filepath) filepath = re.sub(BACKSLASH_REPLACE_PATTERN, '/', filepath)
if WINDOWS_DRIVE_PATTERN.match(filepath): is_windows_drive = WINDOWS_DRIVE_PATTERN.match(filepath)
if is_windows_drive:
filepath = filepath.capitalize() filepath = filepath.capitalize()
if is_windows_network_mount:
# Add back a / to the front, since the previous modifications
# will have replaced any double slashes with single
filepath = '/' + filepath
except: except:
pass pass
return filepath return filepath