MCPcopy Index your code
hub / github.com/kivy/python-for-android / shprint

Function shprint

pythonforandroid/logger.py:131–245  ·  view source on GitHub ↗

Runs the command (which should be an sh.Command instance), while logging the output.

(command, *args, **kwargs)

Source from the content-addressed store, hash-verified

129
130
131def shprint(command, *args, **kwargs):
132 '''Runs the command (which should be an sh.Command instance), while
133 logging the output.'''
134 kwargs["_iter"] = True
135 kwargs["_out_bufsize"] = 1
136 kwargs["_err_to_out"] = True
137 kwargs["_bg"] = True
138
139 # silent mode
140 silent = kwargs.get("silent", False)
141 kwargs.pop("silent", False)
142 if silent:
143 kwargs["_out"] = None
144
145 is_critical = kwargs.pop('_critical', False)
146 tail_n = kwargs.pop('_tail', None)
147 full_debug = False
148 if "P4A_FULL_DEBUG" in os.environ:
149 tail_n = 0
150 full_debug = True
151 filter_in = kwargs.pop('_filter', None)
152 filter_out = kwargs.pop('_filterout', None)
153 if len(logger.handlers) > 1:
154 logger.removeHandler(logger.handlers[1])
155 columns = get_console_width()
156 command_path = str(command).split('/')
157 command_string = command_path[-1]
158 string = ' '.join(['{}->{} running'.format(Out_Fore.LIGHTBLACK_EX,
159 Out_Style.RESET_ALL),
160 command_string] + list(args))
161
162 # If logging is not in DEBUG mode, trim the command if necessary
163 if logger.level > logging.DEBUG:
164 logger.info('{}{}'.format(shorten_string(string, columns - 12),
165 Err_Style.RESET_ALL))
166 else:
167 logger.debug('{}{}'.format(string, Err_Style.RESET_ALL))
168
169 need_closing_newline = False
170 try:
171 msg_hdr = ' working: '
172 msg_width = columns - len(msg_hdr) - 1
173 output = command(*args, **kwargs)
174 for line in output:
175 if isinstance(line, bytes):
176 line = line.decode('utf-8', errors='replace')
177 if logger.level > logging.DEBUG:
178 if full_debug:
179 stdout.write(line)
180 stdout.flush()
181 continue
182 msg = line.replace(
183 '\n', ' ').replace(
184 '\t', ' ').replace(
185 '\b', ' ').rstrip()
186 if msg:
187 if "CI" not in os.environ:
188 stdout.write(u'{}\r{}{:<{width}}'.format(

Callers 15

assemble_distributionMethod · 0.90
distribute_libsMethod · 0.90
_unpack_aarMethod · 0.90
strip_librariesMethod · 0.90
run_setuppy_installFunction · 0.90
process_python_modulesFunction · 0.90
run_pymodules_installFunction · 0.90
biglinkFunction · 0.90
biglink_functionFunction · 0.90
copylibs_functionFunction · 0.90
download_fileMethod · 0.90

Calls 4

get_console_widthFunction · 0.85
shorten_stringFunction · 0.85
printtailFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected