diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py index a25b8ddcb0..683159685d 100644 --- a/pythonforandroid/build.py +++ b/pythonforandroid/build.py @@ -471,6 +471,13 @@ def get_libs_dir(self, arch): return join(self.libs_dir, arch) def has_package(self, name, arch=None): + try: + recipe = Recipe.get_recipe(name, self) + except IOError: + pass + else: + name = getattr(recipe, 'site_packages_name', None) or name + name = name.replace('.', '/') site_packages_dir = self.get_site_packages_dir(arch) return (exists(join(site_packages_dir, name)) or exists(join(site_packages_dir, name + '.py')) or diff --git a/pythonforandroid/logger.py b/pythonforandroid/logger.py index 6e8af698ca..d3ab179ef9 100644 --- a/pythonforandroid/logger.py +++ b/pythonforandroid/logger.py @@ -92,8 +92,27 @@ def shorten_string(string, max_width): return string visible = max_width - 16 - int(log10(string_len)) # expected suffix len "...(and XXXXX more)" - return ''.join((string[:visible], '...(and ', str(string_len - visible), - ' more)')) + return u''.join((string[:visible], u'...(and ', str(string_len - visible), + u' more)')) + + +def get_console_width(): + try: + cols = int(os.environ['COLUMNS']) + except (KeyError, ValueError): + pass + else: + if cols >= 25: + return cols + + try: + cols = max(25, int(os.popen('stty size', 'r').read().split()[1])) + except Exception: + pass + else: + return cols + + return 100 def shprint(command, *args, **kwargs): @@ -109,10 +128,7 @@ def shprint(command, *args, **kwargs): filter_out = kwargs.pop('_filterout', None) if len(logger.handlers) > 1: logger.removeHandler(logger.handlers[1]) - try: - columns = max(25, int(os.popen('stty size', 'r').read().split()[1])) - except: - columns = 100 + columns = get_console_width() command_path = str(command).split('/') command_string = command_path[-1] string = ' '.join(['running', command_string] + list(args))