inorton / EDMCHits

System safety reports for EDMC
34 stars 6 forks source link

EDMCOverlay2/Linux Support? #23

Closed QuicksilverBR closed 3 years ago

QuicksilverBR commented 3 years ago

I discovered HITS earlier today whilst cantering through EDMC's plugins page, and I'm surprised that I missed it before; I really like the way it looks, and indeed how blends into the style of Elite itself. Attempting to run it under Linux (after running the .msi and copying out the result), however, results in the following error:

2021-06-08 13:59:59.388 - INFO - 62386:140004381419328:62386 <plugins>.edmcoverlay._edmcoverlay._Overlay.__init__:37: edmcoverlay2: hiiiiiii
2021-06-08 13:59:59.388 - DEBUG - 62386:140004381419328:62386 <plugins>.edmcoverlay._edmcoverlay._Overlay.__init__:42: edmcoverlay2: init
2021-06-08 13:59:59.388 - INFO - 62386:140004256904768:62401 <plugins>.edmcoverlay._edmcoverlay._Overlay.__server:95: edmcoverlay2: server running
2021-06-08 13:59:59.388 - DEBUG - 62386:140004381419328:62386 <plugins>.edmcoverlay._edmcoverlay.edmcoverlay._edmcoverlay:210: edmcoverlay2: overlay class instantiated
2021-06-08 13:59:59.388 - DEBUG - 62386:140004381419328:62386 <plugins>.edmcoverlay.load.plugin_edmcoverlay:21: edmcoverlay2: got lib: <module 'edmcoverlay' from '/home/bradleyr/.local/share/EDMarketConnector/plugins/edmcoverlay/__init__.py'>
2021-06-08 13:59:59.389 - DEBUG - 62386:140004381419328:62386 <plugins>.edmcoverlay.load.plugin_edmcoverlay:23: edmcoverlay2: got internal lib: <module 'edmcoverlay._edmcoverlay' from '/home/bradleyr/.local/share/EDMarketConnector/plugins/edmcoverlay/_edmcoverlay.py'>
2021-06-08 13:59:59.389 - INFO - 62386:140004381419328:62386 <plugins>.edmcoverlay.load.plugin_start3:66: edmcoverlay2: plugin start!
2021-06-08 13:59:59.389 - INFO - 62386:140004381419328:62386 plug.Plugin.__init__:46: loading plugin "cargo-manifest-2_1_0" from "/home/bradleyr/.local/share/EDMarketConnector/plugins/cargo-manifest-2.1.0/load.py"
2021-06-08 13:59:59.794 - INFO - 62386:140004381419328:62386 plug.Plugin.__init__:46: loading plugin "FuelStatus" from "/home/bradleyr/.local/share/EDMarketConnector/plugins/FuelStatus/load.py"
2021-06-08 13:59:59.794 - DEBUG - 62386:140004381419328:62386 <plugins>.FuelStatus.load.plugin_start3:22: fuelstatus plugin loaded
2021-06-08 13:59:59.794 - INFO - 62386:140004381419328:62386 plug.Plugin.__init__:46: loading plugin "HITS" from "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py"
2021-06-08 13:59:59.796 - ERROR - 62386:140004381419328:62386 plug.Plugin.__init__:61: : Failed for Plugin "HITS"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 52, in __init__
    newname = module.plugin_start3(os.path.dirname(loadfile))
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py", line 43, in plugin_start3
    plugin_start()
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py", line 53, in plugin_start
    _overlay = edmcoverlay.Overlay()
AttributeError: 'NoneType' object has no attribute 'Overlay'
2021-06-08 13:59:59.797 - ERROR - 62386:140004381419328:62386 plug.load_plugins:158: Failure loading found Plugin "HITS"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 156, in load_plugins
    found.append(Plugin(name, os.path.join(config.plugin_dir_path, name, 'load.py'), plugin_logger))
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 52, in __init__
    newname = module.plugin_start3(os.path.dirname(loadfile))
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py", line 43, in plugin_start3
    plugin_start()
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py", line 53, in plugin_start
    _overlay = edmcoverlay.Overlay()
AttributeError: 'NoneType' object has no attribute 'Overlay'

I use EDMCOverlay2 for overlay functionality on Linux so can understand that HITS would be unlikely to work out of the box, but presuming it uses much of the same resources as it's Windows equivalent (EDMCOverlay2 'aims to be 100% compatible with EDMC Overlay'), is there anything that can be done to get it working?

sersorrel commented 3 years ago

edmcoverlay2 author here

I would guess that this is the problem: https://github.com/inorton/EDMCHits/blob/0146f066a854f861c68d0a371c0364e2a032e944/load.py#L11

the other plugins I've tested edmcoverlay2 against (e.g. EDR) do import edmcoverlay, all lowercase. maybe this is a windows case-sensitivity thing? @bradley-r, if you rename the edmcoverlay plugin folder to EDMCOverlay, does it start working?

QuicksilverBR commented 3 years ago

edmcoverlay2 author here

I would guess that this is the problem:

https://github.com/inorton/EDMCHits/blob/0146f066a854f861c68d0a371c0364e2a032e944/load.py#L11

the other plugins I've tested edmcoverlay2 against (e.g. EDR) do import edmcoverlay, all lowercase. maybe this is a windows case-sensitivity thing? @bradley-r, if you rename the edmcoverlay plugin folder to EDMCOverlay, does it start working?

I did try that just in case, but it results in an error stopping the overlay loading completely:

2021-06-08 15:50:42.144 - INFO - 99298:139902969591616:99298 plug.Plugin.__init__:46: loading plugin "EDMCoverlay" from "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCoverlay/load.py"
2021-06-08 15:50:42.144 - DEBUG - 99298:139902969591616:99298 <plugins>.EDMCoverlay.load.plugin_EDMCoverlay:19: edmcoverlay2: loading plugin, importing lib
2021-06-08 15:50:42.145 - ERROR - 99298:139902969591616:99298 plug.Plugin.__init__:61: : Failed for Plugin "EDMCoverlay"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 48, in __init__
    module = importlib.machinery.SourceFileLoader('plugin_{}'.format(
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1034, in load_module
  File "<frozen importlib._bootstrap_external>", line 859, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCoverlay/load.py", line 20, in <module>
    import edmcoverlay
ModuleNotFoundError: No module named 'edmcoverlay'
2021-06-08 15:50:42.145 - ERROR - 99298:139902969591616:99298 plug.load_plugins:158: Failure loading found Plugin "EDMCoverlay"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 156, in load_plugins
    found.append(Plugin(name, os.path.join(config.plugin_dir_path, name, 'load.py'), plugin_logger))
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 48, in __init__
    module = importlib.machinery.SourceFileLoader('plugin_{}'.format(
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1034, in load_module
  File "<frozen importlib._bootstrap_external>", line 859, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCoverlay/load.py", line 20, in <module>
    import edmcoverlay
ModuleNotFoundError: No module named 'edmcoverlay'

HITS still fails with the same issue in this case.

sersorrel commented 3 years ago

oh, of course, argh – if you change that line of edmcoverlay2's load.py to import EDMCOverlay it'll fix that. I'll file a bug to remind me to fix it properly.

QuicksilverBR commented 3 years ago

oh, of course, argh – if you change that line of edmcoverlay2's load.py to import EDMCOverlay it'll fix that. I'll file a bug to remind me to fix it properly.

Apologies for the late response; been busy with finalising some college work. I grabbed a fresh copy of both EDMCOverlay2 and HITS as I tried some manual tinkering to no avail, and when following what was already discussed here (renaming the overlay folder to EDMCOverlay and editing line 20 of load.py) it results in this error, one line further down:

2021-06-09 22:55:25.862 - INFO - 201231:139727149582144:201231 plug.Plugin.__init__:46: loading plugin "EDMCOverlay" from "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCOverlay/load.py"
2021-06-09 22:55:25.862 - DEBUG - 201231:139727149582144:201231 <plugins>.EDMCOverlay.load.plugin_EDMCOverlay:19: edmcoverlay2: loading plugin, importing lib
2021-06-09 22:55:25.863 - DEBUG - 201231:139727149582144:201231 <plugins>.EDMCOverlay._edmcoverlay.EDMCOverlay._edmcoverlay:10: edmcoverlay2: lib loaded
2021-06-09 22:55:25.863 - DEBUG - 201231:139727149582144:201231 <plugins>.EDMCOverlay._edmcoverlay.EDMCOverlay._edmcoverlay:208: edmcoverlay2: instantiating overlay class
2021-06-09 22:55:25.864 - INFO - 201231:139727149582144:201231 <plugins>.EDMCOverlay._edmcoverlay._Overlay.__init__:37: edmcoverlay2: hiiiiiii
2021-06-09 22:55:25.864 - DEBUG - 201231:139727149582144:201231 <plugins>.EDMCOverlay._edmcoverlay._Overlay.__init__:42: edmcoverlay2: init
2021-06-09 22:55:25.864 - INFO - 201231:139727030187584:201243 <plugins>.EDMCOverlay._edmcoverlay._Overlay.__server:95: edmcoverlay2: server running
2021-06-09 22:55:25.864 - DEBUG - 201231:139727149582144:201231 <plugins>.EDMCOverlay._edmcoverlay.EDMCOverlay._edmcoverlay:210: edmcoverlay2: overlay class instantiated
2021-06-09 22:55:25.864 - ERROR - 201231:139727149582144:201231 plug.Plugin.__init__:61: : Failed for Plugin "EDMCOverlay"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 48, in __init__
    module = importlib.machinery.SourceFileLoader('plugin_{}'.format(
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1034, in load_module
  File "<frozen importlib._bootstrap_external>", line 859, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCOverlay/load.py", line 21, in <module>
    logger.debug("edmcoverlay2: got lib: %s", repr(edmcoverlay))
NameError: name 'edmcoverlay' is not defined
2021-06-09 22:55:25.864 - ERROR - 201231:139727149582144:201231 plug.load_plugins:158: Failure loading found Plugin "EDMCOverlay"
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 156, in load_plugins
    found.append(Plugin(name, os.path.join(config.plugin_dir_path, name, 'load.py'), plugin_logger))
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 48, in __init__
    module = importlib.machinery.SourceFileLoader('plugin_{}'.format(
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1034, in load_module
  File "<frozen importlib._bootstrap_external>", line 859, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/EDMCOverlay/load.py", line 21, in <module>
    logger.debug("edmcoverlay2: got lib: %s", repr(edmcoverlay))
NameError: name 'edmcoverlay' is not defined

HITS still returns an AttributeError: 'NoneType' object has no attribute 'Overlay' as above, though of course this time with EDMCOverlay2 out of the equation:

Screenshot_20210609_225158

sersorrel commented 3 years ago

try import EDMCOverlay as edmcoverlay instead; one day I'll learn to proofread comments before I post them

QuicksilverBR commented 3 years ago

try import EDMCOverlay as edmcoverlay instead; one day I'll learn to proofread comments before I post them

I know that feeling. After correcting that, it broke at line 22 of load.py, which I fixed by replacing import edmcoverlay._edmcoverlay with import EDMCOverlay._edmcoverlay. The overlay now launches, confirmed with <plugins>.EDMCOverlay.load.plugin_start3:66: edmcoverlay2: plugin start! and it appearing in the plugin GUI:

Screenshot_20210609_225158 HITS still fails as before, though. I tried opportunistically editing HITS' load.py line 53 to match the formatting above but it only changed the error from a NoneType to NameError: name 'EDMCOverlay' is not defined.

sersorrel commented 3 years ago

weeeeird. can you try, after line 12 of HITS' load.py (except ImportError: ## test mode), inserting a new line with just the word raise on it, indented with 4 spaces like the lines after it? so you end up with something like:

except ImportError:  ## test mode
    raise
    nb = None
    config = dict()
    edmcoverlay = None

then find and post the ImportError that gets logged, along with the traceback that gets logged beforehand, if there is one. then we can actually see what's going wrong!

...on second thought, I think I might know why this is already; you could also try, in edmcoverlay2's __init__.py, adding the line from . import _edmcoverlay as edmcoverlay. (then it should work with an unmodified copy of HITS. I think.)

QuicksilverBR commented 3 years ago

...on second thought, I think I might know why this is already; you could also try, in edmcoverlay2's __init__.py, adding the line from . import _edmcoverlay as edmcoverlay. (then it should work with an unmodified copy of HITS. I think.)

Jumped straight to this and it worked; HITS and LandingPad both work, albeit only on a black screen as already noted. The overlay complains that fonts are unavailable:

unable to load font 9x15bold > using fixed
unable to load font 12x24 > using fixed`

But as you note in the edmcoverlay2 contributing section, XDrawString limits the availability of fonts rather severely, so that's to be expected. HITS itself still throws errors when the settings panel is opened:

2021-06-10 10:09:59.505 - ERROR - 27932:140371990701888:27932 plug.notify_prefs_changed:245: Plugin "HITS" failed
Traceback (most recent call last):
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/plug.py", line 243, in notify_prefs_changed
    prefs_changed(cmdr, is_beta)
  File "/home/bradleyr/.local/share/EDMarketConnector/plugins/HITS/load.py", line 138, in prefs_changed
    config.set(OVERLAY_HITS_MODE, OVERLAY_HITS_MODE.get())
  File "/home/bradleyr/Games (NVME)/Utilities/Elite Dangerous/EDMarketConnector/config.py", line 1016, in set
    self.config.set(self.SECTION, key, to_set)
  File "/usr/lib/python3.9/configparser.py", line 1200, in set
    self._validate_value_types(option=option, value=value)
  File "/usr/lib/python3.9/configparser.py", line 1182, in _validate_value_types
    raise TypeError("option keys must be strings")
TypeError: option keys must be strings

This 'failure' doesn't stop HITS from loading however, nor does it interfere when running multiple times over. I consider this issue resolved with the above course of action - rename edmcoverlay2's folder (until fixed), change line 20 of edmcoverlay2's load.py to import EDMCOverlay as edmcoverlay and line 22 to import EDMCOverlay._edmcoverlay and finally add from . import _edmcoverlay as edmcoverlay to line 2 of edmcoverlay2's __init__.py. Thanks to @sersorrel for the advice, and to @inorton for HITS, other plugins and indeed the original overlay in the first place.

sersorrel commented 3 years ago

fwiw: I've now updated edmcoverlay2 so it should Just Work if the folder it's in is renamed, so if you clone it as EDMCOverlay rather than edmcoverlay then HITS should be able to find it (that is, none of the workarounds in this issue should be needed any more).

it's not a great approach, not least because it means you can't use HITS together with plugins that do import edmcoverlay all-lowercase, but I'm working on it, and hopefully I'll have a better solution in the future.

TheK0tYaRa commented 2 years ago

But what if...

...
from edmcoverlay import edmcoverlay # from EDMCOverlay import edmcoverlay
...