mendix / m2ee-tools

m2ee, the Mendix runtime helper tools for GNU/Linux
Other
27 stars 40 forks source link

m2ee barfing when STDOUT redirected/piped #63

Open hevisko opened 2 years ago

hevisko commented 2 years ago

m2ee about & status both throw TypeError is seems when output is redirected/piped

acw2@agw-acw-mx01-prod ~ % m2ee about
Using m2ee-tools version 7.2.2
Using Mendix Runtime version 8.18.14.33751
Copyright © 2003-2021 Mendix bv. All rights reserved.
Model version: 3.0.0.1432
acw2@agw-acw-mx01-prod ~ % ls
acw2  m2ee-tools-7.2.3  mx-build.sh  rr.awk
acw2@agw-acw-mx01-prod ~ % m2ee status
INFO: The application process is running, the MxRuntime has status: running
INFO: Logged in users: (1) ['Anonymous_24973d9b-35ae-4258-a635-950a920af4a6']
acw2@agw-acw-mx01-prod ~ % m2ee status | grep running
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1082, in emit
    stream.write(msg + self.terminator)
  File "/usr/lib/python3.9/codecs.py", line 378, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes
Call stack:
  File "/usr/local/bin/m2ee", line 1050, in <module>
    main()
  File "/usr/local/bin/m2ee", line 1029, in main
    cli.unchecked_onecmd(' '.join(args.onecmd))
  File "/usr/local/bin/m2ee", line 857, in unchecked_onecmd
    super(CLI, self).onecmd(line)
  File "/usr/lib/python3.9/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/bin/m2ee", line 283, in do_status
    logger.info("The application process is running, the MxRuntime has status: %s" % status)
Message: 'The application process is running, the MxRuntime has status: running'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1082, in emit
    stream.write(msg + self.terminator)
  File "/usr/lib/python3.9/codecs.py", line 378, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes
Call stack:
  File "/usr/local/bin/m2ee", line 1050, in <module>
    main()
  File "/usr/local/bin/m2ee", line 1029, in main
    cli.unchecked_onecmd(' '.join(args.onecmd))
  File "/usr/local/bin/m2ee", line 857, in unchecked_onecmd
    super(CLI, self).onecmd(line)
  File "/usr/lib/python3.9/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/bin/m2ee", line 294, in do_status
    total_users = self._who(max_show_users)
  File "/usr/local/bin/m2ee", line 815, in _who
    logger.info("Logged in users: (%s) %s" %
Message: "Logged in users: (1) ['Anonymous_24973d9b-35ae-4258-a635-950a920af4a6']"
Arguments: ()
acw2@agw-acw-mx01-prod ~ %
 % m2ee about | cat
Traceback (most recent call last):
  File "/usr/local/bin/m2ee", line 1050, in <module>
    main()
  File "/usr/local/bin/m2ee", line 1029, in main
    cli.unchecked_onecmd(' '.join(args.onecmd))
  File "/usr/local/bin/m2ee", line 857, in unchecked_onecmd
    super(CLI, self).onecmd(line)
  File "/usr/lib/python3.9/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/bin/m2ee", line 361, in do_about
    print('Using m2ee-tools version %s' % m2ee.__version__)
  File "/usr/lib/python3.9/codecs.py", line 378, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes
hvisage commented 11 months ago

m2ee still doesn't work as great inside supervisor/etc.

hevisko commented 11 months ago

This is even more... challenging, when using Ansible ;(

hvisage commented 10 months ago

I've made a PR (but seems it's included in my pg_restore commits/PR ;( ) that makes a small change to m2ee(.py) to have a m2ee-pipe command be executing in the same why when piped or on "terminal", ie. easier for Ansible playbooks: https://github.com/mendix/m2ee-tools/pull/70/commits/5cc3f956ebb66dd49fac605d4b1d6aa70d286bca #70