upgraded wakatime package to v0.2.0 for Python3 support
This commit is contained in:
parent
49a7878712
commit
94d954517d
4 changed files with 30 additions and 9 deletions
|
@ -12,7 +12,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
__title__ = 'wakatime'
|
__title__ = 'wakatime'
|
||||||
__version__ = '0.1.5'
|
__version__ = '0.2.0'
|
||||||
__author__ = 'Alan Hamlett'
|
__author__ = 'Alan Hamlett'
|
||||||
__license__ = 'BSD'
|
__license__ = 'BSD'
|
||||||
__copyright__ = 'Copyright 2013 Alan Hamlett'
|
__copyright__ = 'Copyright 2013 Alan Hamlett'
|
||||||
|
@ -27,11 +27,18 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import urllib2
|
try:
|
||||||
|
from urllib2 import HTTPError, Request, urlopen
|
||||||
|
except ImportError:
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
from .log import setup_logging
|
from .log import setup_logging
|
||||||
from .project import find_project
|
from .project import find_project
|
||||||
from .packages import argparse
|
try:
|
||||||
|
import argparse
|
||||||
|
except ImportError:
|
||||||
|
from .packages import argparse
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -130,15 +137,16 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
|
||||||
if tags:
|
if tags:
|
||||||
data['tags'] = list(set(tags))
|
data['tags'] = list(set(tags))
|
||||||
log.debug(data)
|
log.debug(data)
|
||||||
request = urllib2.Request(url=url, data=json.dumps(data))
|
request = Request(url=url, data=str.encode(json.dumps(data)))
|
||||||
user_agent = get_user_agent(plugin)
|
user_agent = get_user_agent(plugin)
|
||||||
request.add_header('User-Agent', user_agent)
|
request.add_header('User-Agent', user_agent)
|
||||||
request.add_header('Content-Type', 'application/json')
|
request.add_header('Content-Type', 'application/json')
|
||||||
request.add_header('Authorization', 'Basic %s' % base64.b64encode(key))
|
auth = 'Basic %s' % bytes.decode(base64.b64encode(str.encode(key)))
|
||||||
|
request.add_header('Authorization', auth)
|
||||||
response = None
|
response = None
|
||||||
try:
|
try:
|
||||||
response = urllib2.urlopen(request)
|
response = urlopen(request)
|
||||||
except urllib2.HTTPError as exc:
|
except HTTPError as exc:
|
||||||
data = {
|
data = {
|
||||||
'response_code': exc.getcode(),
|
'response_code': exc.getcode(),
|
||||||
'response_content': exc.read(),
|
'response_content': exc.read(),
|
||||||
|
|
|
@ -22,6 +22,9 @@ except ImportError:
|
||||||
class CustomEncoder(json.JSONEncoder):
|
class CustomEncoder(json.JSONEncoder):
|
||||||
|
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
|
if isinstance(obj, bytes):
|
||||||
|
obj = bytes.decode(obj)
|
||||||
|
return json.dumps(obj)
|
||||||
return super(CustomEncoder, self).default(obj)
|
return super(CustomEncoder, self).default(obj)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@ import os
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
from .base import BaseProject
|
from .base import BaseProject
|
||||||
from ..packages.ordereddict import OrderedDict
|
try:
|
||||||
|
from collections import OrderedDict
|
||||||
|
except ImportError:
|
||||||
|
from ..packages.ordereddict import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -67,6 +70,8 @@ class Git(BaseProject):
|
||||||
pass
|
pass
|
||||||
if stdout:
|
if stdout:
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
|
if isinstance(line, bytes):
|
||||||
|
line = bytes.decode(line)
|
||||||
line = line.split(' ', 1)
|
line = line.split(' ', 1)
|
||||||
if line[0] == '*':
|
if line[0] == '*':
|
||||||
return line[1]
|
return line[1]
|
||||||
|
|
|
@ -14,7 +14,10 @@ import os
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
from .base import BaseProject
|
from .base import BaseProject
|
||||||
from ..packages.ordereddict import OrderedDict
|
try:
|
||||||
|
from collections import OrderedDict
|
||||||
|
except ImportError:
|
||||||
|
from ..packages.ordereddict import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -51,6 +54,8 @@ class Subversion(BaseProject):
|
||||||
'URL',
|
'URL',
|
||||||
]
|
]
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
|
if isinstance(line, bytes):
|
||||||
|
line = bytes.decode(line)
|
||||||
line = line.split(': ', 1)
|
line = line.split(': ', 1)
|
||||||
if line[0] in interesting:
|
if line[0] in interesting:
|
||||||
info[line[0]] = line[1]
|
info[line[0]] = line[1]
|
||||||
|
|
Loading…
Reference in a new issue