turn svn output into unicode before parsing
This commit is contained in:
parent
edb1dab9a8
commit
eff141187b
3 changed files with 43 additions and 8 deletions
|
@ -95,6 +95,30 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
|
|
||||||
self.assertEquals('svn', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
|
self.assertEquals('svn', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
|
||||||
|
|
||||||
|
def test_svn_exception_handled(self):
|
||||||
|
response = Response()
|
||||||
|
response.status_code = 0
|
||||||
|
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||||
|
|
||||||
|
with utils.mock.patch('wakatime.projects.git.Git.process') as mock_git:
|
||||||
|
mock_git.return_value = False
|
||||||
|
|
||||||
|
with utils.mock.patch('wakatime.projects.subversion.Popen') as mock_popen:
|
||||||
|
mock_popen.side_effect = OSError('')
|
||||||
|
|
||||||
|
with utils.mock.patch('wakatime.projects.subversion.Popen.communicate') as mock_communicate:
|
||||||
|
mock_communicate.side_effect = OSError('')
|
||||||
|
|
||||||
|
now = u(int(time.time()))
|
||||||
|
entity = 'tests/samples/projects/svn/emptyfile.txt'
|
||||||
|
config = 'tests/samples/sample.cfg'
|
||||||
|
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
execute(args)
|
||||||
|
|
||||||
|
self.assertNotIn('project', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0])
|
||||||
|
|
||||||
def test_project_map(self):
|
def test_project_map(self):
|
||||||
response = Response()
|
response = Response()
|
||||||
response.status_code = 0
|
response.status_code = 0
|
||||||
|
|
|
@ -26,9 +26,12 @@ if is_py2: # pragma: nocover
|
||||||
return text.decode('utf-8')
|
return text.decode('utf-8')
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
return unicode(text)
|
return text.decode(sys.getdefaultencoding())
|
||||||
except:
|
except:
|
||||||
return text
|
try:
|
||||||
|
return unicode(text)
|
||||||
|
except:
|
||||||
|
return text
|
||||||
open = codecs.open
|
open = codecs.open
|
||||||
basestring = basestring
|
basestring = basestring
|
||||||
|
|
||||||
|
@ -39,8 +42,17 @@ elif is_py3: # pragma: nocover
|
||||||
if text is None:
|
if text is None:
|
||||||
return None
|
return None
|
||||||
if isinstance(text, bytes):
|
if isinstance(text, bytes):
|
||||||
return text.decode('utf-8')
|
try:
|
||||||
return str(text)
|
return text.decode('utf-8')
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
return text.decode(sys.getdefaultencoding())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
return str(text)
|
||||||
|
except:
|
||||||
|
return text
|
||||||
open = open
|
open = open
|
||||||
basestring = (str, bytes)
|
basestring = (str, bytes)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ from ..compat import u, open
|
||||||
try:
|
try:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ..packages.ordereddict import OrderedDict
|
from ..packages.ordereddict import OrderedDict # pragma: nocover
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('WakaTime')
|
log = logging.getLogger('WakaTime')
|
||||||
|
@ -69,8 +69,7 @@ class Subversion(BaseProject):
|
||||||
else:
|
else:
|
||||||
if stdout:
|
if stdout:
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
if isinstance(line, bytes):
|
line = u(line)
|
||||||
line = bytes.decode(line)
|
|
||||||
line = line.split(': ', 1)
|
line = line.split(': ', 1)
|
||||||
if len(line) == 2:
|
if len(line) == 2:
|
||||||
info[line[0]] = line[1]
|
info[line[0]] = line[1]
|
||||||
|
@ -78,7 +77,7 @@ class Subversion(BaseProject):
|
||||||
|
|
||||||
def _find_project_base(self, path, found=False):
|
def _find_project_base(self, path, found=False):
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
return False
|
return False # pragma: nocover
|
||||||
path = os.path.realpath(path)
|
path = os.path.realpath(path)
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
path = os.path.split(path)[0]
|
path = os.path.split(path)[0]
|
||||||
|
|
Loading…
Reference in a new issue