upgraded wakatime package to v0.4.0
This commit is contained in:
parent
dda5da361c
commit
969e5ba1bd
6 changed files with 29 additions and 40 deletions
|
@ -2,6 +2,12 @@
|
||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
0.4.0 (2013-08-15)
|
||||||
|
++++++++++++++++++
|
||||||
|
|
||||||
|
- Sending single branch instead of multiple tags
|
||||||
|
|
||||||
|
|
||||||
0.3.1 (2013-08-08)
|
0.3.1 (2013-08-08)
|
||||||
++++++++++++++++++
|
++++++++++++++++++
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
__title__ = 'wakatime'
|
__title__ = 'wakatime'
|
||||||
__version__ = '0.3.1'
|
__version__ = '0.4.0'
|
||||||
__author__ = 'Alan Hamlett'
|
__author__ = 'Alan Hamlett'
|
||||||
__license__ = 'BSD'
|
__license__ = 'BSD'
|
||||||
__copyright__ = 'Copyright 2013 Alan Hamlett'
|
__copyright__ = 'Copyright 2013 Alan Hamlett'
|
||||||
|
@ -120,7 +120,7 @@ def get_user_agent(plugin):
|
||||||
return user_agent
|
return user_agent
|
||||||
|
|
||||||
|
|
||||||
def send_action(project=None, tags=None, key=None, targetFile=None,
|
def send_action(project=None, branch=None, key=None, targetFile=None,
|
||||||
timestamp=None, endtime=None, isWrite=None, plugin=None, **kwargs):
|
timestamp=None, endtime=None, isWrite=None, plugin=None, **kwargs):
|
||||||
url = 'https://www.wakati.me/api/v1/actions'
|
url = 'https://www.wakati.me/api/v1/actions'
|
||||||
log.debug('Sending action to api at %s' % url)
|
log.debug('Sending action to api at %s' % url)
|
||||||
|
@ -134,8 +134,8 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
|
||||||
data['is_write'] = isWrite
|
data['is_write'] = isWrite
|
||||||
if project:
|
if project:
|
||||||
data['project'] = project
|
data['project'] = project
|
||||||
if tags:
|
if branch:
|
||||||
data['tags'] = list(set(tags))
|
data['branch'] = branch
|
||||||
log.debug(data)
|
log.debug(data)
|
||||||
|
|
||||||
# setup api request headers
|
# setup api request headers
|
||||||
|
@ -175,13 +175,13 @@ def main(argv=None):
|
||||||
args = parseArguments(argv)
|
args = parseArguments(argv)
|
||||||
setup_logging(args, __version__)
|
setup_logging(args, __version__)
|
||||||
if os.path.isfile(args.targetFile):
|
if os.path.isfile(args.targetFile):
|
||||||
tags = []
|
branch = None
|
||||||
name = None
|
name = None
|
||||||
project = find_project(args.targetFile)
|
project = find_project(args.targetFile)
|
||||||
if project:
|
if project:
|
||||||
tags = project.tags()
|
branch = project.branch()
|
||||||
name = project.name()
|
name = project.name()
|
||||||
if send_action(project=name, tags=tags, **vars(args)):
|
if send_action(project=name, branch=branch, **vars(args)):
|
||||||
return 0
|
return 0
|
||||||
return 102
|
return 102
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -47,8 +47,7 @@ class BaseProject(object):
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def tags(self):
|
def branch(self):
|
||||||
""" Returns an array of tag strings for the
|
""" Returns the current branch.
|
||||||
path and/or project.
|
|
||||||
"""
|
"""
|
||||||
return []
|
return None
|
||||||
|
|
|
@ -37,29 +37,7 @@ class Git(BaseProject):
|
||||||
return os.path.basename(base)
|
return os.path.basename(base)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def tags(self):
|
def branch(self):
|
||||||
tags = []
|
|
||||||
if self.config:
|
|
||||||
proj_name = self.name()
|
|
||||||
if proj_name:
|
|
||||||
tags.append(proj_name)
|
|
||||||
sections = self._parse_config()
|
|
||||||
for section in sections:
|
|
||||||
if section.split(' ', 1)[0] == 'remote' and 'url' in sections[section]:
|
|
||||||
remote = sections[section]['url'].rsplit(':', 1)[-1].rsplit('/', 1)[-1].split('.git', 1)[0]
|
|
||||||
if remote:
|
|
||||||
tags.append(remote)
|
|
||||||
branch = self._current_branch()
|
|
||||||
if branch is not None:
|
|
||||||
tags.append(branch)
|
|
||||||
return tags
|
|
||||||
|
|
||||||
def _project_base(self):
|
|
||||||
if self.config:
|
|
||||||
return os.path.dirname(os.path.dirname(self.config))
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _current_branch(self):
|
|
||||||
stdout = None
|
stdout = None
|
||||||
try:
|
try:
|
||||||
stdout, stderr = Popen([
|
stdout, stderr = Popen([
|
||||||
|
@ -77,6 +55,12 @@ class Git(BaseProject):
|
||||||
return line[1]
|
return line[1]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _project_base(self):
|
||||||
|
if self.config:
|
||||||
|
return os.path.dirname(os.path.dirname(self.config))
|
||||||
|
return None
|
||||||
|
|
||||||
def _find_config(self, path):
|
def _find_config(self, path):
|
||||||
path = os.path.realpath(path)
|
path = os.path.realpath(path)
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
|
|
|
@ -26,5 +26,5 @@ class Mercurial(BaseProject):
|
||||||
def name(self):
|
def name(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def tags(self):
|
def branch(self):
|
||||||
return []
|
return None
|
||||||
|
|
|
@ -31,11 +31,11 @@ class Subversion(BaseProject):
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.info['Repository Root'].split('/')[-1]
|
return self.info['Repository Root'].split('/')[-1]
|
||||||
|
|
||||||
def tags(self):
|
def branch(self):
|
||||||
tags = []
|
branch = None
|
||||||
if self.base:
|
if self.base:
|
||||||
tags.append(os.path.basename(self.base))
|
branch = os.path.basename(self.base)
|
||||||
return tags
|
return branch
|
||||||
|
|
||||||
def _get_info(self, path):
|
def _get_info(self, path):
|
||||||
info = OrderedDict()
|
info = OrderedDict()
|
||||||
|
|
Loading…
Reference in a new issue