- show environment to debug before run

This commit is contained in:
maho 2019-01-13 16:29:35 +01:00
parent 5a912a7949
commit da9d59f96e

View file

@ -11,7 +11,6 @@ __version__ = '0.38.dev0'
import os import os
import re import re
import sys import sys
import zipfile
import select import select
import codecs import codecs
import textwrap import textwrap
@ -24,6 +23,9 @@ from os import environ, unlink, walk, sep, listdir, makedirs
from copy import copy from copy import copy
from shutil import copyfile, rmtree, copytree, move from shutil import copyfile, rmtree, copytree, move
from fnmatch import fnmatch from fnmatch import fnmatch
from pprint import pformat
try: try:
from urllib.request import FancyURLopener from urllib.request import FancyURLopener
from configparser import SafeConfigParser from configparser import SafeConfigParser
@ -41,7 +43,7 @@ try:
colorama.init() colorama.init()
RESET_SEQ = colorama.Fore.RESET + colorama.Style.RESET_ALL RESET_SEQ = colorama.Fore.RESET + colorama.Style.RESET_ALL
COLOR_SEQ = lambda x: x COLOR_SEQ = lambda x: x # noqa: E731
BOLD_SEQ = '' BOLD_SEQ = ''
if sys.platform == 'win32': if sys.platform == 'win32':
BLACK = colorama.Fore.BLACK + colorama.Style.DIM BLACK = colorama.Fore.BLACK + colorama.Style.DIM
@ -54,7 +56,7 @@ try:
except ImportError: except ImportError:
if sys.platform != 'win32': if sys.platform != 'win32':
RESET_SEQ = "\033[0m" RESET_SEQ = "\033[0m"
COLOR_SEQ = lambda x: "\033[1;{}m".format(30 + x) COLOR_SEQ = lambda x: "\033[1;{}m".format(30 + x) # noqa: E731
BOLD_SEQ = "\033[1m" BOLD_SEQ = "\033[1m"
BLACK = 0 BLACK = 0
RED = 1 RED = 1
@ -73,11 +75,13 @@ LOG_LEVELS_T = 'EID'
SIMPLE_HTTP_SERVER_PORT = 8000 SIMPLE_HTTP_SERVER_PORT = 8000
IS_PY3 = sys.version_info[0] >= 3 IS_PY3 = sys.version_info[0] >= 3
class ChromeDownloader(FancyURLopener): class ChromeDownloader(FancyURLopener):
version = ( version = (
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36') '(KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36')
urlretrieve = ChromeDownloader().retrieve urlretrieve = ChromeDownloader().retrieve
@ -132,7 +136,7 @@ class Buildozer(object):
try: try:
self.log_level = int(self.config.getdefault( self.log_level = int(self.config.getdefault(
'buildozer', 'log_level', '1')) 'buildozer', 'log_level', '1'))
except: except Exception:
pass pass
build_dir = self.config.getdefault('buildozer', 'builddir', None) build_dir = self.config.getdefault('buildozer', 'builddir', None)
@ -233,6 +237,12 @@ class Buildozer(object):
def debug(self, msg): def debug(self, msg):
self.log(2, msg) self.log(2, msg)
def debug_env(self, env):
"""dump env into debug logger in readable format"""
self.debug("ENVIRONMENT:")
for k, v in env.items():
self.debug(" {} = {}".format(k, pformat(v)))
def info(self, msg): def info(self, msg):
self.log(1, msg) self.log(1, msg)
@ -282,6 +292,7 @@ class Buildozer(object):
else: else:
self.debug('Run {0!r} ...'.format(command.split()[0])) self.debug('Run {0!r} ...'.format(command.split()[0]))
self.debug('Cwd {}'.format(kwargs.get('cwd'))) self.debug('Cwd {}'.format(kwargs.get('cwd')))
self.debug_env(kwargs.get("env"))
# open the process # open the process
if sys.platform == 'win32': if sys.platform == 'win32':
@ -482,7 +493,7 @@ class Buildozer(object):
return return
# remove all the requirements that the target can compile # remove all the requirements that the target can compile
onlyname = lambda x: x.split('==')[0] onlyname = lambda x: x.split('==')[0] # noqa: E731
requirements = [x for x in requirements if onlyname(x) not in requirements = [x for x in requirements if onlyname(x) not in
target_available_packages] target_available_packages]