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