return
+ # -------------------------------------------------------------------------
+ def print_out(self, *objects, sep=' ', end='\n', file=sys.stdout.buffer, flush=True):
+
+ file.write(to_bytes(sep.join(map(lambda x: str(x), objects))))
+ if end:
+ file.write(to_bytes(end))
+ if flush:
+ file.flush()
+
# -------------------------------------------------------------------------
def __call__(self):
"""Helper method to make the resulting object callable."""
'user_name': 'Frank Brehm'}
"""
- print("Content-Type: text/plain;charset=utf-8")
- print()
- sys.stdout.buffer.write(to_bytes("Python CGI läuft.\n"))
+ #print("Content-Type: text/plain;charset=utf-8")
+ #print()
+ #sys.stdout.buffer.write(to_bytes("Python CGI läuft.\n"))
+ #sys.stdout.flush()
+ self.print_out("Content-Type: text/plain;charset=utf-8\n")
+ self.print_out("Python CGI läuft.\n")
LOG.info("Starting ...")
LOG.debug("Base directory: {!r}".format(self.base_dir))
n=e.__class__.__name__, e=e))
LOG.error("Traceback:\n{}".format(traceback.format_exc()))
+ LOG.info("Finished.")
sys.exit(0)
# -------------------------------------------------------------------------
LOG.debug("Return value: {}".format(ret_val))
if stdoutdata:
- LOG.debug("Output:\n{}".format(to_str(stdoutdata)))
+ msg = "Output:\n{}".format(to_str(stdoutdata))
+ LOG.debug(msg)
+ self.print_out(msg)
else:
LOG.debug("No output.")
if stderrdata:
- LOG.warn("Error messages on '{c}': {e}".format(c=cmd_str, e=to_str(stderrdata)))
+ msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
+ LOG.warn(msg)
+ self.print_out(msg)
# =============================================================================