Skip to content

[Plugin] Unable to load using absolute path #726

Open
@moham96

Description

@moham96

Describe the bug
This states that one can load a plugin simply by using the absolute path for the plugin but it's not working for me

python -m proxy --log-level d --ca-key-file ca-key.pem --ca-cert-file ca-cert.pem --ca-signing-key-file ca-signing-key.pem --plugins /home/mohammad/repos/plugintest/proxyPlugin.proxyPlugin
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/mohammad/repos/proxy.py/proxy/__main__.py", line 14, in <module>
    entry_point()
  File "/home/mohammad/repos/proxy.py/proxy/proxy.py", line 176, in entry_point
    main(input_args=sys.argv[1:])
  File "/home/mohammad/repos/proxy.py/proxy/proxy.py", line 155, in main
    with Proxy(input_args=input_args, **opts):
  File "/home/mohammad/repos/proxy.py/proxy/proxy.py", line 105, in __init__
    self.flags = FlagParser.initialize(input_args, **opts)
  File "/home/mohammad/repos/proxy.py/proxy/common/flag.py", line 100, in initialize
    Plugins.discover(input_args)
  File "/home/mohammad/repos/proxy.py/proxy/common/plugins.py", line 38, in discover
    Plugins.importer(bytes_(part))
  File "/home/mohammad/repos/proxy.py/proxy/common/plugins.py", line 75, in importer
    importlib.import_module(
  File "/usr/lib/python3.9/importlib/__init__.py", line 122, in import_module
    raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '.home.mohammad.repos.plugintest.proxyPlugin'

To Reproduce
Steps to reproduce the behavior:
1- create a simple plugin in a directory outside proxy.py tree for me i created a directory at /home/mohammad/repos/plugintest/ that contains a file named proxyPlugin.py the file contains a plugin class named proxyPlugin
2. Run proxy.py as python -m proxy --log-level d --ca-key-file ca-key.pem --ca-cert-file ca-cert.pem --ca-signing-key-file ca-signing-key.pem --plugins /home/mohammad/repos/plugintest/proxyPlugin.proxyPlugin
3- The following exception is raised TypeError: the 'package' argument is required to perform a relative import for '.home.mohammad.repos.plugintest.proxyPlugin'

Expected behavior
According to the README.md file using the absolute path for the plugin should work just fine

Version information

  • OS: Manjaro linux

  • Device: Desktop pc

  • proxy.py version: git version

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug report in proxy serverGood First IssueIssues for new contributors to pick-up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions