Compare commits
3 Commits
7a4ddda2e3
...
f03bc7ec26
Author | SHA1 | Date |
---|---|---|
Luna | f03bc7ec26 | |
Luna | d581d0ced2 | |
Luna | 4ad45d3a01 |
|
@ -38,3 +38,5 @@ virtualenv
|
||||||
venv/
|
venv/
|
||||||
venv3/
|
venv3/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
.mypy_cache/
|
||||||
|
|
34
README.rst
34
README.rst
|
@ -1,30 +1,13 @@
|
||||||
.. image:: https://travis-ci.org/wakatime/wakatime.svg
|
rana-cli
|
||||||
:target: https://travis-ci.org/wakatime/wakatime
|
|
||||||
:alt: Tests
|
|
||||||
|
|
||||||
.. image:: https://ci.appveyor.com/api/projects/status/g9snpluqi8svrgbn/branch/master?svg=true
|
|
||||||
:target: https://ci.appveyor.com/project/alanhamlett/wakatime-jl10s/branch/master
|
|
||||||
:alt: Windows Tests
|
|
||||||
|
|
||||||
.. image:: https://coveralls.io/repos/wakatime/wakatime/badge.svg?branch=master&service=github
|
|
||||||
:target: https://coveralls.io/github/wakatime/wakatime?branch=master
|
|
||||||
:alt: Coverage
|
|
||||||
|
|
||||||
.. image:: https://img.shields.io/pypi/v/wakatime.svg
|
|
||||||
:target: https://pypi.python.org/pypi/wakatime
|
|
||||||
:alt: Version
|
|
||||||
|
|
||||||
.. image:: https://img.shields.io/pypi/pyversions/wakatime.svg
|
|
||||||
:target: https://pypi.python.org/pypi/wakatime
|
|
||||||
:alt: Supported Python Versions
|
|
||||||
|
|
||||||
|
|
||||||
WakaTime
|
|
||||||
========
|
========
|
||||||
|
|
||||||
Command line interface to `WakaTime <https://wakatime.com/>`_ used by all WakaTime `text editor plugins <https://wakatime.com/editors>`_.
|
Command line interface to `rana <https://github.com/lnyaa/rana/>`_.
|
||||||
|
|
||||||
Go to http://wakatime.com/editors to install the plugin for your text editor or IDE.
|
This is a fork of the wakatime CLI tool for use with rana.
|
||||||
|
|
||||||
|
Rana is not affiliated with WakaTime.
|
||||||
|
|
||||||
|
Go to http://gitdab.com/lavatech to install the plugin for your text editor or IDE.
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
@ -56,6 +39,8 @@ Some more usage information is available in the `FAQ <https://wakatime.com/faq>`
|
||||||
Configuring
|
Configuring
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
`The only modification from a original config file is the api_key field`
|
||||||
|
|
||||||
Options can be passed via command line, or set in the ``$WAKATIME_HOME/.wakatime.cfg``
|
Options can be passed via command line, or set in the ``$WAKATIME_HOME/.wakatime.cfg``
|
||||||
config file. Command line arguments take precedence over config file settings.
|
config file. Command line arguments take precedence over config file settings.
|
||||||
The ``$WAKATIME_HOME/.wakatime.cfg`` file is in `INI <http://en.wikipedia.org/wiki/INI_file>`_
|
The ``$WAKATIME_HOME/.wakatime.cfg`` file is in `INI <http://en.wikipedia.org/wiki/INI_file>`_
|
||||||
|
@ -64,6 +49,7 @@ format. An example config file with all available options::
|
||||||
[settings]
|
[settings]
|
||||||
debug = false
|
debug = false
|
||||||
api_key = your-api-key
|
api_key = your-api-key
|
||||||
|
base_url = https://your-rana-instance.com
|
||||||
hide_file_names = false
|
hide_file_names = false
|
||||||
hide_project_names = false
|
hide_project_names = false
|
||||||
exclude =
|
exclude =
|
||||||
|
|
|
@ -38,6 +38,11 @@ except ImportError: # pragma: nocover
|
||||||
sys.exit(UNKNOWN_ERROR)
|
sys.exit(UNKNOWN_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
def _make_url(configs, path):
|
||||||
|
base_url = configs.get('settings', 'base_url') or 'https://api.wakatime.com'
|
||||||
|
return '%s%s' % (base_url, path)
|
||||||
|
|
||||||
|
|
||||||
def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
||||||
"""Send heartbeats to WakaTime API.
|
"""Send heartbeats to WakaTime API.
|
||||||
|
|
||||||
|
@ -47,9 +52,7 @@ def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
||||||
if len(heartbeats) == 0:
|
if len(heartbeats) == 0:
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
|
|
||||||
api_url = args.api_url
|
api_url = _make_url(configs, '/api/v1/users/current/heartbeats.bulk')
|
||||||
if not api_url:
|
|
||||||
api_url = 'https://api.wakatime.com/api/v1/users/current/heartbeats.bulk'
|
|
||||||
log.debug('Sending heartbeats to api at %s' % api_url)
|
log.debug('Sending heartbeats to api at %s' % api_url)
|
||||||
timeout = args.timeout
|
timeout = args.timeout
|
||||||
if not timeout:
|
if not timeout:
|
||||||
|
@ -163,7 +166,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_time_today(args, use_ntlm_proxy=False):
|
def get_time_today(args, configs, 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
|
||||||
|
@ -171,7 +174,7 @@ def get_time_today(args, use_ntlm_proxy=False):
|
||||||
fetch summary.
|
fetch summary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = 'https://api.wakatime.com/api/v1/users/current/summaries'
|
url = _make_url(configs, '/api/v1/users/current/summaries')
|
||||||
timeout = args.timeout
|
timeout = args.timeout
|
||||||
if not timeout:
|
if not timeout:
|
||||||
timeout = 60
|
timeout = 60
|
||||||
|
@ -219,7 +222,7 @@ def get_time_today(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_time_today(args, use_ntlm_proxy=True)
|
return get_time_today(args, configs, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -233,7 +236,7 @@ def get_time_today(args, use_ntlm_proxy=False):
|
||||||
|
|
||||||
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_time_today(args, use_ntlm_proxy=True)
|
return get_time_today(args, configs, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -264,7 +267,7 @@ def get_time_today(args, use_ntlm_proxy=False):
|
||||||
return None, API_ERROR
|
return None, API_ERROR
|
||||||
else:
|
else:
|
||||||
if should_try_ntlm:
|
if should_try_ntlm:
|
||||||
return get_time_today(args, use_ntlm_proxy=True)
|
return get_time_today(args, configs, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
log.debug({
|
log.debug({
|
||||||
|
|
|
@ -43,7 +43,7 @@ def execute(argv=None):
|
||||||
setup_logging(args, __version__)
|
setup_logging(args, __version__)
|
||||||
|
|
||||||
if args.today:
|
if args.today:
|
||||||
text, retval = get_time_today(args)
|
text, retval = get_time_today(args, configs)
|
||||||
if text:
|
if text:
|
||||||
print(text)
|
print(text)
|
||||||
return retval
|
return retval
|
||||||
|
|
Loading…
Reference in New Issue