mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
7755971d11 | |||
7634be5446 | |||
5e17ad88f6 | |||
24d0f65116 | |||
a326046733 |
13
HISTORY.rst
13
HISTORY.rst
@ -3,6 +3,19 @@ History
|
||||
-------
|
||||
|
||||
|
||||
7.0.11 (2016-09-23)
|
||||
++++++++++++++++++
|
||||
|
||||
- Handle UnicodeDecodeError when when logging. Related to #68.
|
||||
|
||||
|
||||
7.0.10 (2016-09-22)
|
||||
++++++++++++++++++
|
||||
|
||||
- Handle UnicodeDecodeError when looking for python. Fixes #68.
|
||||
- Upgrade wakatime-cli to v6.0.9.
|
||||
|
||||
|
||||
7.0.9 (2016-09-02)
|
||||
++++++++++++++++++
|
||||
|
||||
|
13
WakaTime.py
13
WakaTime.py
@ -7,7 +7,7 @@ Website: https://wakatime.com/
|
||||
==========================================================="""
|
||||
|
||||
|
||||
__version__ = '7.0.9'
|
||||
__version__ = '7.0.11'
|
||||
|
||||
|
||||
import sublime
|
||||
@ -54,7 +54,7 @@ if is_py2:
|
||||
try:
|
||||
return unicode(text)
|
||||
except:
|
||||
return text
|
||||
return text.decode('utf-8', 'replace')
|
||||
|
||||
elif is_py3:
|
||||
def u(text):
|
||||
@ -71,7 +71,7 @@ elif is_py3:
|
||||
try:
|
||||
return str(text)
|
||||
except:
|
||||
return text
|
||||
return text.decode('utf-8', 'replace')
|
||||
|
||||
else:
|
||||
raise Exception('Unsupported Python version: {0}.{1}.{2}'.format(
|
||||
@ -135,7 +135,10 @@ def log(lvl, message, *args, **kwargs):
|
||||
msg = message.format(*args)
|
||||
elif len(kwargs) > 0:
|
||||
msg = message.format(**kwargs)
|
||||
print('[WakaTime] [{lvl}] {msg}'.format(lvl=lvl, msg=msg))
|
||||
try:
|
||||
print('[WakaTime] [{lvl}] {msg}'.format(lvl=lvl, msg=msg))
|
||||
except UnicodeDecodeError:
|
||||
print(u('[WakaTime] [{lvl}] {msg}').format(lvl=lvl, msg=u(msg)))
|
||||
except RuntimeError:
|
||||
set_timeout(lambda: log(lvl, message, *args, **kwargs), 0)
|
||||
|
||||
@ -314,7 +317,7 @@ def find_python_in_folder(folder, headless=True):
|
||||
path = os.path.realpath(os.path.join(folder, 'python'))
|
||||
if headless:
|
||||
path = u(path) + u('w')
|
||||
log(DEBUG, u('Looking for Python at: {0}').format(path))
|
||||
log(DEBUG, u('Looking for Python at: {0}').format(u(path)))
|
||||
try:
|
||||
process = Popen([path, '--version'], stdout=PIPE, stderr=STDOUT)
|
||||
output, err = process.communicate()
|
||||
|
@ -1,7 +1,7 @@
|
||||
__title__ = 'wakatime'
|
||||
__description__ = 'Common interface to the WakaTime api.'
|
||||
__url__ = 'https://github.com/wakatime/wakatime'
|
||||
__version_info__ = ('6', '0', '8')
|
||||
__version_info__ = ('6', '0', '9')
|
||||
__version__ = '.'.join(__version_info__)
|
||||
__author__ = 'Alan Hamlett'
|
||||
__author_email__ = 'alan@wakatime.com'
|
||||
|
@ -471,6 +471,17 @@ def sync_offline_heartbeats(args, hostname):
|
||||
return SUCCESS
|
||||
|
||||
|
||||
def format_file_path(filepath):
|
||||
"""Formats a path as absolute and with the correct platform separator."""
|
||||
|
||||
try:
|
||||
filepath = os.path.realpath(os.path.abspath(filepath))
|
||||
filepath = re.sub(r'[/\\]', os.path.sep, filepath)
|
||||
except:
|
||||
pass # pragma: nocover
|
||||
return filepath
|
||||
|
||||
|
||||
def process_heartbeat(args, configs, hostname, heartbeat):
|
||||
exclude = should_exclude(heartbeat['entity'], args.include, args.exclude)
|
||||
if exclude is not False:
|
||||
@ -482,6 +493,9 @@ def process_heartbeat(args, configs, hostname, heartbeat):
|
||||
if heartbeat.get('entity_type') not in ['file', 'domain', 'app']:
|
||||
heartbeat['entity_type'] = 'file'
|
||||
|
||||
if heartbeat['entity_type'] == 'file':
|
||||
heartbeat['entity'] = format_file_path(heartbeat['entity'])
|
||||
|
||||
if heartbeat['entity_type'] != 'file' or os.path.isfile(heartbeat['entity']):
|
||||
|
||||
stats = get_file_stats(heartbeat['entity'],
|
||||
|
@ -37,7 +37,7 @@
|
||||
"""
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
except (ImportError, IOError):
|
||||
pkg_resources = None
|
||||
|
||||
LEXER_ENTRY_POINT = 'pygments.lexers'
|
||||
|
Reference in New Issue
Block a user