use upstream pexpect instead of shipping it

this version allows unicode parsing, with spawnu
wrap stdout with codecs.getwriter('utf8') to avoid another unicode error
This commit is contained in:
gabriel pettier 2015-01-02 18:28:53 +01:00
parent 1bd6579582
commit ac5c557cd2
5 changed files with 7 additions and 1861 deletions

View file

@ -13,6 +13,7 @@ import re
import sys
import zipfile
import select
import codecs
from buildozer.jsonstore import JsonStore
from sys import stdout, stderr, exit
from re import search
@ -324,7 +325,7 @@ class Buildozer(object):
process.returncode)
def cmd_expect(self, command, **kwargs):
from buildozer.libs.pexpect import spawn
from pexpect import spawnu
# prepare the environ, based on the system + our own env
env = copy(environ)
@ -337,7 +338,7 @@ class Buildozer(object):
show_output = kwargs.pop('show_output')
if show_output:
kwargs['logfile'] = stdout
kwargs['logfile'] = codecs.getwriter('utf8')(stdout)
if not sensible:
self.debug('Run (expect) {0!r}'.format(command))
@ -345,7 +346,7 @@ class Buildozer(object):
self.debug('Run (expect) {0!r} ...'.format(command.split()[0]))
self.debug('Cwd {}'.format(kwargs.get('cwd')))
return spawn(command, **kwargs)
return spawnu(command, **kwargs)
def check_configuration_tokens(self):
'''Ensure the spec file is 'correct'.

File diff suppressed because it is too large Load diff

View file

@ -301,7 +301,7 @@ class TargetAndroid(Target):
available_packages.splitlines() if x.startswith('id: ')]
def _android_update_sdk(self, packages):
from buildozer.libs.pexpect import EOF
from pexpect import EOF
java_tool_options = environ.get('JAVA_TOOL_OPTIONS', '')
child = self.buildozer.cmd_expect('{} update sdk -u -a -t {}'.format(
self.android_cmd, packages,
@ -309,7 +309,7 @@ class TargetAndroid(Target):
timeout=None,
env={'JAVA_TOOL_OPTIONS': java_tool_options + ' -Dfile.encoding=UTF-8'})
while True:
index = child.expect([EOF, '[y/n]: '])
index = child.expect([EOF, u'[y/n]: '])
if index == 0:
break
child.sendline('y')

View file

@ -47,6 +47,7 @@ setup(
'buildozer.scripts'],
package_data={'buildozer': ['default.spec']},
include_package_data=True,
install_requires=['pexpect'],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',