Commit 7288b06b authored by Matthias Putz's avatar Matthias Putz

extracted some changes to portable module + solved stringio problem

parent ef40ad0e
This diff is collapsed.
......@@ -20,6 +20,7 @@ import subprocess
import tempfile
from signal import SIGTERM
from error import GitError
import portable
from repo_trace import REPO_TRACE, IsTrace, Trace
GIT = 'git'
......@@ -79,7 +80,7 @@ class _GitCall(object):
def version(self):
p = GitCommand(None, ['--version'], capture_stdout=True)
if p.Wait() == 0:
return str(p.stdout, encoding='UTF-8')
return portable.stream2str(p.stdout)
return None
def version_tuple(self):
......
......@@ -19,6 +19,8 @@ import os
import re
import subprocess
import sys
import portable
try:
import threading as _threading
except ImportError:
......@@ -324,7 +326,7 @@ class GitConfig(object):
capture_stdout = True,
capture_stderr = True)
if p.Wait() == 0:
return str(p.stdout, encoding='UTF-8')
return portable.stream2str(p.stdout)
else:
GitError('git config %s: %s' % (str(args), p.stderr))
......
......@@ -10,6 +10,9 @@ import subprocess
SYNC_REPO_PROGRAM = False
def stream2str(stream):
return str(stream, encoding='UTF-8')
def isLinux():
if platform.system() == "Windows":
return False
......
......@@ -735,7 +735,7 @@ class Project(object):
return 'CLEAN'
out = StatusColoring(self.config)
if not output_redir == None:
if not output_redir is None:
out.redirect(output_redir)
out.project('project %-40s', self.relpath + '/')
......@@ -2019,7 +2019,7 @@ class Project(object):
if p.Wait() == 0:
out = p.stdout
if out:
return out[:-1].split('\0') # pylint: disable=W1401
return portable.stream2str(out)[:-1].split('\0') # pylint: disable=W1401
# Backslash is not anomalous
return []
......
......@@ -16,9 +16,8 @@
<excludeFolder url="file://$MODULE_DIR$/docs" />
<excludeFolder url="file://$MODULE_DIR$/hooks" />
</content>
<orderEntry type="jdk" jdkName="Python 3.2.3 (/usr/bin/python3)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.3.0 (/usr/bin/python3.3)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.2.3 (/usr/bin/python3) interpreter library" level="application" />
</component>
</module>
......@@ -18,6 +18,7 @@ import re
import sys
from command import Command
from git_command import GitCommand
import portable
CHANGE_ID_RE = re.compile(r'^\s*Change-Id: I([0-9a-f]{40})\s*$')
......@@ -55,7 +56,7 @@ change id will be added.
if p.Wait() != 0:
print("error: Failed to retrieve old commit message", file=sys.stderr)
sys.exit(1)
old_msg = self._StripHeader(str(p.stdout, encoding='UTF-8'))
old_msg = self._StripHeader(portable.stream2str(p.stdout))
p = GitCommand(None,
['cherry-pick', sha1],
......
......@@ -18,6 +18,7 @@ import sys
from color import Coloring
from command import PagedCommand
from git_command import git_require, GitCommand
import portable
class GrepColoring(Coloring):
def __init__(self, config):
......@@ -210,7 +211,7 @@ contain a line that matches both expressions:
# We cut the last element, to avoid a blank line.
#
r = str(p.stdout, encoding='UTF-8').split('\n')
r = portable.stream2str(p.stdout).split('\n')
r = r[0:-1]
if have_rev and full_name:
......
......@@ -142,11 +142,9 @@ the following meanings:
for project in all_projects:
sem.acquire()
class BufList(io.StringIO.StringIO):
class BufList(io.StringIO):
def dump(self, ostream):
for entry in self.buflist:
ostream.write(entry)
ostream.write(self.getvalue())
output = BufList()
t = _threading.Thread(target=self._StatusHelper,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment