Page 1 of 1

macOS: TypeError: _log() got an unexpected keyword argument 'file'

Published: June 25, 2020 - 8:07 PM
by marcolefo
Good morning,

I am testing the installation of agent 1.8.2.7265 under macOS 10.15.5

It crashes during registration. I imagine it's a Python version issue. I'm posting here in case it helps.
But if it can be resolved, I'm all for it ;)

Good evening

Code: Select all

# python --version 
Python 2.7.16
# wapt-get register -l debug
2020-06-25 19:55:22,220 DEBUG Default encoding : ascii 
2020-06-25 19:55:22,220 DEBUG Setting encoding for stdout and stderr to UTF-8 
2020-06-25 19:55:22,220 DEBUG Python path ['/opt/wapt', '/opt/wapt', '/opt/wapt/lib/python27.zip', '/opt/wapt/lib/python2.7', '/opt/wapt/lib/python2.7/plat-darwin', '/opt/wapt/lib/python2.7/plat-mac', '/opt/wapt/lib/python2.7/plat-mac/lib-scriptpackages', '/opt/wapt/lib/python2.7/lib-tk', '/opt/wapt/lib/python2.7/lib-old', '/opt/wapt/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/opt/wapt/lib/python2.7/site-packages']
2020-06-25 19:55:22,220 INFO Using local waptservice configuration /opt/wapt/wapt-get.ini 
2020-06-25 19:55:22,220 DEBUG Config file: /opt/wapt/wapt-get.ini
Using config file: /opt/wapt/wapt-get.ini
2020-06-25 19:55:22,224 DEBUG Thread 4514852288 is connecting to wapt db
2020-06-25 19:55:22,228 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:22,253 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:22,256 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:22,392 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:22,421 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:22,448 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:22,450 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:22,585 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:22,589 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:22,625 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:22,626 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:22,755 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:22,760 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:22,784 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:22,786 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:22,918 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:22,920 DEBUG Using host certificate /opt/wapt/private/A35C8C6C-FDCE-5F1F-BDF6-E83297815CB9.pem for repo global auth
2020-06-25 19:55:22,922 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:22,945 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:22,946 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,074 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,078 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,100 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,101 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,234 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,237 DEBUG Thread 4514852288 is connecting to wapt db
2020-06-25 19:55:23,237 DEBUG DB Start transaction
2020-06-25 19:55:23,238 DEBUG DB commit
2020-06-25 19:55:23,242 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,263 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,264 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,447 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,452 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,474 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,478 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,614 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,619 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,644 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,646 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,775 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,780 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,803 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,804 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:23,939 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:23,942 DEBUG Using host certificate /opt/wapt/private/A35C8C6C-FDCE-5F1F-BDF6-E83297815CB9.pem for repo wapt auth
2020-06-25 19:55:23,943 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:23,966 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:23,967 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,104 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,109 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,131 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,132 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,265 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,268 INFO Main repository: https://wapt.domain/wapt
2020-06-25 19:55:24,271 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,295 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,297 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,426 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,429 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,450 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,452 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,587 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,593 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,614 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,615 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,743 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,747 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,770 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,772 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:24,904 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:24,908 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:24,932 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:24,934 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:25,064 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:25,069 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:25,092 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:25,094 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:25,224 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:25,226 DEBUG Using host certificate /opt/wapt/private/A35C8C6C-FDCE-5F1F-BDF6-E83297815CB9.pem for repo wapt-host auth
2020-06-25 19:55:25,228 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:25,251 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:25,252 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:25,382 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:25,386 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:25,410 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:25,411 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:25,535 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:25,538 INFO User Groups:[]
2020-06-25 19:55:25,538 DEBUG WAPT base directory : /opt/wapt
2020-06-25 19:55:25,538 DEBUG Package cache dir : /opt/wapt/cache
2020-06-25 19:55:25,538 DEBUG WAPT DB Structure version;: 20200415
Registering host against server: https://wapt.domain/
2020-06-25 19:55:25,538 DEBUG DB Start transaction
2020-06-25 19:55:25,539 DEBUG DB commit
2020-06-25 19:55:25,545 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:25,571 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:25,572 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:25,707 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:25,709 DEBUG DB Start transaction
2020-06-25 19:55:25,709 DEBUG DB commit
2020-06-25 19:55:25,711 DEBUG DB Start transaction
2020-06-25 19:55:25,711 DEBUG DB commit
2020-06-25 19:55:25,724 INFO Run "route get default"
2020-06-25 19:55:25,738 INFO route get default command returns code 0
2020-06-25 19:55:26,885 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:26,911 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:26,912 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:27,042 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:27,045 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:27,175 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:27,246 DEBUG DB Start transaction
2020-06-25 19:55:27,250 DEBUG DB commit
2020-06-25 19:55:27,253 DEBUG Stores cert chain check in cache
2020-06-25 19:55:27,257 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:27,281 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:27,282 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:27,413 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:27,420 INFO Run "dmidecode -q 2>/dev/null"
2020-06-25 19:55:27,443 INFO dmidecode -q 2>/dev/null command returns code 0
2020-06-25 19:55:27,444 INFO Run "system_profiler SPHardwareDataType -xml"
2020-06-25 19:55:27,579 INFO system_profiler SPHardwareDataType -xml command returns code 0
2020-06-25 19:55:27,585 INFO Run "file /Applications/VLC.app/Contents/Info.plist"
2020-06-25 19:55:27,600 INFO file /Applications/VLC.app/Contents/Info.plist command returns code 0
2020-06-25 19:55:27,630 INFO Run "file /Applications/nextcloud.app/Contents/Info.plist"
2020-06-25 19:55:27,653 INFO file /Applications/nextcloud.app/Contents/Info.plist command returns code 0
FATAL ERROR : TypeError: _log() got an unexpected keyword argument 'file'
Traceback (most recent call last):
  File "/opt/wapt//wapt-get.py", line 1462, in <module>
    main()
  File "/opt/wapt//wapt-get.py", line 1241, in main
    description=(" ".join(args[1:])).decode(sys.getfilesystemencoding()),
  File "/opt/wapt/common.py", line 5621, in register_computer
    inv = self._get_host_status_data(old_hashes, new_hashes, force=True, include_dmi=True, include_wmi=True)
  File "/opt/wapt/common.py", line 5945, in _get_host_status_data
    _add_data_if_updated(inv,'installed_softwares',self.merge_installed_softwares_and_wua_list(),old_hashes,new_hashes)
  File "/opt/wapt/common.py", line 6110, in merge_installed_softwares_and_wua_list
    soft_inventory = setuphelpers.installed_softwares()
  File "/opt/wapt/setuphelpers_macos.py", line 433, in installed_softwares
    logger.warning("Application data acquisition failed for {} :".format(plist_file), file=sys.stderr)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1186, in warning
    self._log(WARNING, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'file'

Re: macOS: TypeError: _log() got an unexpected keyword argument 'file'

Published: June 25, 2020 - 10:20 PM
by sfonteneau
seems to be a problem during the inventory process with the Nextcloud application (I'm not certain).

We need to use a try-except block during the inventory to prevent it from crashing.

I'm going to install Nextcloud on the Mac to see if that's the issue,

Simon.

Re: macOS: TypeError: _log() got an unexpected keyword argument 'file'

Published: June 25, 2020 - 10:48 PM
by sfonteneau
Indeed, the code needs a small patch:

In the file /opt/wapt/setuphelpers_macos.py, line 433

Code: Select all

else:
            #logger.warning("Application data acquisition failed for {} :".format(plist_file), file=sys.stderr)
            logger.warning("Application data acquisition failed for {} :".format(plist_file))
The Nextcloud application apparently does not have a CFBundleName
https://developer.apple.com/documentati ...bundlename

Re: macOS: TypeError: _log() got an unexpected keyword argument 'file'

Published: July 2, 2020 - 3:13 PM
by MisterP
Hello,

I'm indeed experiencing the same problem; modifying the line fixes it.
Do you have a version that includes the fix directly?


Thank you.