Skip to content

Commit e6de4c8

Browse files
committed
Merge pull request kivy#539 from kived/various-fixes
Various fixes
2 parents f7d3c94 + 1833ae9 commit e6de4c8

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

pythonforandroid/build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,13 @@ def get_libs_dir(self, arch):
471471
return join(self.libs_dir, arch)
472472

473473
def has_package(self, name, arch=None):
474+
try:
475+
recipe = Recipe.get_recipe(name, self)
476+
except IOError:
477+
pass
478+
else:
479+
name = getattr(recipe, 'site_packages_name', None) or name
480+
name = name.replace('.', '/')
474481
site_packages_dir = self.get_site_packages_dir(arch)
475482
return (exists(join(site_packages_dir, name)) or
476483
exists(join(site_packages_dir, name + '.py')) or

pythonforandroid/logger.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,27 @@ def shorten_string(string, max_width):
9292
return string
9393
visible = max_width - 16 - int(log10(string_len))
9494
# expected suffix len "...(and XXXXX more)"
95-
return ''.join((string[:visible], '...(and ', str(string_len - visible),
96-
' more)'))
95+
return u''.join((string[:visible], u'...(and ', str(string_len - visible),
96+
u' more)'))
97+
98+
99+
def get_console_width():
100+
try:
101+
cols = int(os.environ['COLUMNS'])
102+
except (KeyError, ValueError):
103+
pass
104+
else:
105+
if cols >= 25:
106+
return cols
107+
108+
try:
109+
cols = max(25, int(os.popen('stty size', 'r').read().split()[1]))
110+
except Exception:
111+
pass
112+
else:
113+
return cols
114+
115+
return 100
97116

98117

99118
def shprint(command, *args, **kwargs):
@@ -109,10 +128,7 @@ def shprint(command, *args, **kwargs):
109128
filter_out = kwargs.pop('_filterout', None)
110129
if len(logger.handlers) > 1:
111130
logger.removeHandler(logger.handlers[1])
112-
try:
113-
columns = max(25, int(os.popen('stty size', 'r').read().split()[1]))
114-
except:
115-
columns = 100
131+
columns = get_console_width()
116132
command_path = str(command).split('/')
117133
command_string = command_path[-1]
118134
string = ' '.join(['running', command_string] + list(args))

0 commit comments

Comments
 (0)