Repository: ultrabug/py3status

Issue:
Importing module from entry_point doesn't work the same as importing from .i3/py3status/
I've written a small http monitoring module that I want to call multiple times. This works if I put the module in `~/.i3/py3status`.

With a config block like: 
```
...
order += "http_monitor apache"
order += "http_monitor medusa"

http_monitor 'apache' {
   service_location = "http://host:81"
   service_name = '🪶'
}

http_monitor 'medusa' {
   service_location = "http://host:8081"
   service_name = '🐍'
}
...
```

Working from `~/.i3/py3status/` the py3status log.
```
2021-03-06 22:38:53 INFO modules include paths: [PosixPath('/home/j/.i3/py3status')]
2021-03-06 22:38:53 INFO available module from /home/j/.i3/py3status: http_monitor
2021-03-06 22:38:53 INFO loading module "http_monitor apache" from /home/j/.i3/py3status/http_monitor.py
2021-03-06 22:38:53 INFO loading module "http_monitor medusa" from /home/j/.i3/py3status/http_monitor.py
```

So this method has been working correctly for quite some time for me. 

However I wanted to package this as an Arch package AUR, and to install packages with `pacman` generally it's best practice to never put any files in the users home directory. 

So I figured I'd just convert my module to use the `entry_point` since this has worked for some of the other modules I've written for py3status and built Arch packages for. But I'm getting an error trying to pass it parameters when importing it this way.

```
2021-03-06 22:56:33 INFO available module from entry_point: http_monitor
2021-03-06 22:56:33 INFO Module `http_monitor apache` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-06 22:56:33 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-06 22:56:33 INFO Module `http_monitor medusa` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-06 22:56:33 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
```

The module works correctly if I don't pass it a parameter using the `entry_point`, but then I can only have 1 instance of it running. 

Any ideas 💭 


Discussion:
>since this has worked for some of the other modules

Might be a regression bug from #1978.
Get us one more log with `py3status --debug` flag.
/cc https://github.com/eumiro
```
2021-03-07 13:12:07 INFO received SIGTERM
2021-03-07 13:12:07 INFO lock set, exiting
2021-03-07 13:12:08 INFO ========
2021-03-07 13:12:08 INFO Starting py3status version 3.34 python 3.9.2
2021-03-07 13:12:08 INFO window manager: i3
2021-03-07 13:12:08 INFO py3status started with config {'dbus_notify': False, 'i3status_config_path': PosixPath('/home/j/.config/i3/i3status.conf'), 'debug': True, 'gevent': False, 'include_paths': [PosixPath('/home/j/.i3/py3status')], 'log_file': PosixPath('/tmp/py3status.log'), 'standalone': False, 'cache_timeout': 60, 'i3status_path': PosixPath('/usr/bin/i3status'), 'wm': {'msg': 'i3-msg', 'nag': 'i3-nagbar'}, 'python_version': '3.9.2', 'version': '3.34', 'wm_name': 'i3', 'minimum_interval': 0.1, 'click_events': True}
2021-03-07 13:12:08 INFO config file: /home/j/.config/i3/i3status.conf
2021-03-07 13:12:08 INFO i3status thread mocked with config {'general': {'color_bad': '#FF0000', 'color_degraded': '#FFFF00', 'color_good': '#00FF00', 'color_separator': '#333333', 'colors': True, 'interval': 15, 'output_format': 'i3bar'}, 'py3status': ModuleDefinition([('align', 'left'), ('markup', 'pango'), ('min_width', 5), ('separator', True), ('separator_block_width', 50), ('background', '#282A36'), ('border', '#44475A'), ('border_bottom', 1), ('border_left', 1), ('border_right', 1), ('border_top', 1), ('min_length', 5), ('position', 'right')]), 'order': ['cpu_governor', 'http_monitor apache', 'http_monitor medusa', 'http_monitor pihole', 'http_monitor nextcloud', 'http_monitor plex', 'http_monitor virtualbox', 'http_monitor airsonic', 'clock', 'mail', 'sysdata', 'diskdata /', 'lm_sensors', 'loadavg', 'netdata', 'uname', 'uptime', 'arch_updates', 'ups_battery_status', 'volume_status'], 'cpu_governor': {}, 'http_monitor apache': {'service_location': 'http://ryzen:81', 'service_name': '🪶'}, 'http_monitor medusa': {'service_location': 'http://ryzen:8081', 'service_name': '🐍'}, 'http_monitor pihole': {'service_location': 'http://ryzen:80', 'service_name': '🕳️'}, 'http_monitor nextcloud': {'service_location': 'http://ryzen:8181', 'service_name': '⛅'}, 'http_monitor plex': {'service_location': 'http://ryzen:32400/web/index.html#', 'service_name': '🎥'}, 'http_monitor virtualbox': {'service_location': 'http://ryzen:81/vb/', 'service_name': '💻'}, 'http_monitor airsonic': {'service_location': 'http://ryzen:4040', 'service_name': '🍃'}, 'clock': {'format': '{America/Halifax}', 'format_time': '%l:%M:%S %b(%m)-%A(%e)-%Y'}, 'mail': {'cache_timeout': 3600, 'accounts': {'imap': [{'name': '****', 'user': '*****', 'password': '******', 'server': 'imap.gmail.com', 'port': 993}]}, 'allow_urgent': False}, 'sysdata': {}, 'diskdata /': {}, 'lm_sensors': {'chips': ['amdgpu-pci-1000', 'nvme-pci-0100', 'k10temp-pci-00c3'], 'sensors': ['tdie', 'mem'], 'format_chip': '{format_sensor}', 'format_sensor': '[\\?if=name=tdie 5900x CPU ][\\?if=name=mem Vega64 GPU ][\\?color=auto.input {input}°C]'}, 'loadavg': {}, 'netdata': {'cache_timeout': 5, 'format': '{nic} [\\?color=down (Mb): {down}↓ {up}↑]'}, 'uname': {}, 'uptime': {}, 'arch_updates': {'cache_timeout': 1800, 'hide_if_zero': True}, 'ups_battery_status': {}, 'volume_status': {}, 'on_click': {}, 'i3s_modules': [], 'py3_modules': ['cpu_governor', 'http_monitor apache', 'http_monitor medusa', 'http_monitor pihole', 'http_monitor nextcloud', 'http_monitor plex', 'http_monitor virtualbox', 'http_monitor airsonic', 'clock', 'mail', 'sysdata', 'diskdata /', 'lm_sensors', 'loadavg', 'netdata', 'uname', 'uptime', 'arch_updates', 'ups_battery_status', 'volume_status'], '.module_groups': {}}
2021-03-07 13:12:08 INFO events thread started
2021-03-07 13:12:08 INFO Unix domain socket at /tmp/py3status_uds.1321692
2021-03-07 13:12:08 INFO commands thread started
2021-03-07 13:12:08 INFO modules include paths: [PosixPath('/home/j/.i3/py3status')]
2021-03-07 13:12:08 INFO waiting for a connection
2021-03-07 13:12:08 INFO available module from entry_point: ups_battery_status
2021-03-07 13:12:08 INFO available module from entry_point: http_monitor
2021-03-07 13:12:08 INFO available module from entry_point: cpu_governor
2021-03-07 13:12:08 INFO user_modules={'ups_battery_status': ('entry_point', <class 'py3status_ups_battery_status.ups_battery_status.Py3status'>), 'http_monitor': ('entry_point', <class 'py3status_http_monitor.http_monitor.Py3status'>), 'cpu_governor': ('entry_point', <class 'py3status_cpu_governor.cpu_governor.Py3status'>)}
2021-03-07 13:12:08 INFO module "cpu_governor" click_events=False has_kill=False methods=['cpu_governor']
2021-03-07 13:12:08 INFO Module `http_monitor apache` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor medusa` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor pihole` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor nextcloud` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor plex` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor virtualbox` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO Module `http_monitor airsonic` could not be loaded (unsupported operand type(s) for /: 'PosixPath' and 'type')
2021-03-07 13:12:08 INFO unsupported operand type(s) for /: 'PosixPath' and 'type'
2021-03-07 13:12:08 INFO loading module "clock" from py3status.modules.clock
2021-03-07 13:12:08 INFO module "clock" click_events=new has_kill=False methods=['clock']
2021-03-07 13:12:08 INFO loading module "mail" from py3status.modules.mail
2021-03-07 13:12:08 INFO module "mail" click_events=False has_kill=False methods=['mail']
2021-03-07 13:12:08 INFO loading module "sysdata" from py3status.modules.sysdata
2021-03-07 13:12:08 INFO module "sysdata" click_events=False has_kill=False methods=['sysdata']
2021-03-07 13:12:08 INFO loading module "diskdata /" from py3status.modules.diskdata
2021-03-07 13:12:08 INFO module "diskdata /" click_events=False has_kill=False methods=['diskdata']
2021-03-07 13:12:08 INFO loading module "lm_sensors" from py3status.modules.lm_sensors
2021-03-07 13:12:08 INFO module "lm_sensors" click_events=False has_kill=False methods=['lm_sensors']
2021-03-07 13:12:08 INFO loading module "loadavg" from py3status.modules.loadavg
2021-03-07 13:12:08 INFO module "loadavg" click_events=False has_kill=False methods=['loadavg']
2021-03-07 13:12:08 INFO loading module "netdata" from py3status.modules.netdata
2021-03-07 13:12:08 INFO module "netdata" click_events=False has_kill=False methods=['netdata']
2021-03-07 13:12:08 INFO loading module "uname" from py3status.modules.uname
2021-03-07 13:12:08 INFO module "uname" click_events=False has_kill=False methods=['uname']
2021-03-07 13:12:08 INFO loading module "uptime" from py3status.modules.uptime
2021-03-07 13:12:08 INFO module "uptime" click_events=False has_kill=False methods=['uptime']
2021-03-07 13:12:08 INFO loading module "arch_updates" from py3status.modules.arch_updates
2021-03-07 13:12:08 INFO module "arch_updates" click_events=False has_kill=False methods=['arch_updates']
2021-03-07 13:12:08 INFO module "ups_battery_status" click_events=False has_kill=False methods=['ups_battery_status']
2021-03-07 13:12:08 INFO loading module "volume_status" from py3status.modules.volume_status
2021-03-07 13:12:08 INFO module "volume_status" click_events=new has_kill=False methods=['volume_status']
2021-03-07 13:12:08 INFO starting module cpu_governor
2021-03-07 13:12:08 INFO starting module mail
2021-03-07 13:12:08 INFO storage_path: /home/j/.cache/py3status_cache.data
2021-03-07 13:12:08 INFO starting module sysdata
2021-03-07 13:12:08 INFO storage_data: {'clock': {'timezone': '{America/Halifax}', '_ctime': 1614050385.555661, '_mtime': 1614050385.555661}}
2021-03-07 13:12:08 INFO starting module clock
2021-03-07 13:12:08 INFO starting module loadavg
2021-03-07 13:12:08 INFO starting module diskdata /
2021-03-07 13:12:08 INFO Module `netdata`: selected nic: enp6s0
2021-03-07 13:12:08 INFO starting module uptime
2021-03-07 13:12:08 INFO starting module uname
2021-03-07 13:12:08 INFO starting module netdata
2021-03-07 13:12:08 INFO starting module ups_battery_status
2021-03-07 13:12:08 INFO method cpu_governor returned {'composite': [{'full_text': '💻: schedutil', 'markup': 'pango', 'min_width': 5, 'align': 'left', 'separator': True, 'separator_block_width': 50, 'instance': ' 0', 'name': 'cpu_governor', 'background': '#282A36', 'border': '#44475A', 'border_top': 1, 'border_right': 1, 'border_bottom': 1, 'border_left': 1}], 'instance': '', 'name': 'cpu_governor'}
```
Didn't tag right first time. @eumiro
@lasers could we get a full traceback for any error in a module?
https://github.com/mcgillij/py3status-http-monitor/blob/main/src/py3status_http_monitor/http_monitor.py This is the module that I'm having issues with if it helps. I can add whatever debugging to the module if needed.
@eumiro IIRC `--debug` usually prints module exceptions. The log showed that the modules doesn't get loaded so py3status exceptions anywhere are sometimes not shown. Here's a PR introducing this. #1823
I'm not on i3wm / py3status. I guess maybe this one. https://github.com/ultrabug/py3status/blob/fda88d102ef17116ea27581aa99a8d9796cdb668/py3status/module.py#L590 
I put up a PR, not sure if this is the right way to fix it since I'm not super familiar with your codebase, if you can take a peek would be appreciated: https://github.com/ultrabug/py3status/pull/2022

Resolving patch:
diff --git a/py3status/core.py b/py3status/core.py
--- a/py3status/core.py
+++ b/py3status/core.py
@@ -505,7 +505,7 @@ def load_modules(self, modules_list, user_modules):
                 continue
             try:
                 instance = None
-                payload = user_modules.get(module)
+                payload = user_modules.get(module.split(" ")[0])
                 if payload:
                     kind, Klass = payload
                     if kind == ENTRY_POINT_KEY:


Test patch: