Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during execution #23

Open
Kr4k0w opened this issue Dec 16, 2024 · 1 comment
Open

Error during execution #23

Kr4k0w opened this issue Dec 16, 2024 · 1 comment

Comments

@Kr4k0w
Copy link

Kr4k0w commented Dec 16, 2024

Traceback (most recent call last):
File "/usr/local/bin/ds4drv", line 33, in
sys.exit(load_entry_point('ds4drv==0.5.1', 'console_scripts', 'ds4drv')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/bin/ds4drv", line 25, in importlib_load_entry_point
return next(matches).load()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/metadata/init.py", line 205, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in _call_with_frames_removed
File "/usr/local/lib/python3.12/dist-packages/ds4drv-0.5.1-py3.12.egg/ds4drv/main.py", line 6, in
File "/usr/local/lib/python3.12/dist-packages/ds4drv-0.5.1-py3.12.egg/ds4drv/actions/init.py", line 1, in
File "/usr/local/lib/python3.12/dist-packages/ds4drv-0.5.1-py3.12.egg/ds4drv/action.py", line 1, in
File "/usr/local/lib/python3.12/dist-packages/ds4drv-0.5.1-py3.12.egg/ds4drv/config.py", line 72, in
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?

@Kr4k0w
Copy link
Author

Kr4k0w commented Dec 16, 2024

The issue arises because configparser.SafeConfigParser has been removed in modern Python versions (3.2 and above). It should be replaced with configparser.ConfigParser to maintain compatibility.

Proposed Fix:

Replace all instances of configparser.SafeConfigParser with configparser.ConfigParser. Additionally, ensure that method calls like sections() are updated to reference the correct class.

class Config(configparser.ConfigParser):
    def load(self, filename):
        self.read([filename])

    def section_to_args(self, section):
        args = []

        for key, value in self.section(section).items():
            if value.lower() == "true":
                args.append("--{0}".format(key))
            elif value.lower() == "false":
                pass
            else:
                args.append("--{0}={1}".format(key, value))

        return args

    def sections(self, prefix=None):
        for section in configparser.ConfigParser.sections(self):  # Updated SafeConfigParser
            match = re.match(r"{0}:(.+)".format(prefix), section)
            if match:
                yield match.group(1), section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant