uyuni-project / uyuni

Source code for Uyuni
https://www.uyuni-project.org/
GNU General Public License v2.0
434 stars 181 forks source link

mgr-sync returns General error: can't set attribute #8473

Open pj256 opened 7 months ago

pj256 commented 7 months ago

Problem description

mgr-sync reports "General error: can't set attribute" when run.

mgr-sync -v -d3 list channels

General error: can't set attribute Traceback (most recent call last): File "/usr/sbin/mgr-sync", line 27, in sys.exit(MgrSync().run(options)) File "/usr/lib/python3.6/site-packages/spacewalk/susemanager/mgr_sync/mgr_sync.py", line 60, in init self.config.port = 443 AttributeError: can't set attribute

This was introduced in https://github.com/uyuni-project/uyuni/commit/5ba17e77c081172d24d1a7eacc132b0108e52d0e

This is a simple fix. It occurs because the port does not have a @port.setter defined in /usr/lib/python3.6/site-packages/spacewalk/susemanager/mgr_sync/config.py . For example, add the below to /usr/lib/python3.6/site-packages/spacewalk/susemanager/mgr_sync/config.py to fix:

@port.setter  # pylint: disable=E1101
def port(self, value):  # pylint: disable=E0102
    self._config[Config.PORT] = value

Steps to reproduce

1. 2. 3. ...

Uyuni version

2024.02-230900.213.1.uyuni3

Uyuni proxy version (if used)

No response

Useful logs

No response

Additional information

No response

avshiliaev commented 6 months ago

@cbosdo @meaksh please take a look. :smiley:

Teamspeak5 commented 4 months ago

Hi @pj256, I've got the same issue on mine, any try of launching the command "mgr-sync " with any parameter returns as a result: General error: can't set attribute

I've then checked the content of the file config.py as you mentioned, but here's a snippet of its content :

class Config(object):
    """
    Handle mgr-sync settings.
    """

    # Configuration location
    RHN = "/etc/rhn"
    HOME = os.path.expanduser("~")
    DOTFILE = os.path.join(HOME, ".mgr-sync")
    RHNFILE = os.path.join(RHN, "rhn.conf")

    # Keys of the configuration
    K_PREF = "mgrsync"
    USER = K_PREF + ".user"
    PASSWORD = K_PREF + ".password"
    HOST = K_PREF + ".host"
    PORT = K_PREF + ".port"
    URI = K_PREF + ".uri"
    TOKEN = K_PREF + ".session.token"
    DEBUG = K_PREF + ".debug"

    def __init__(self):
        # Default configuration, if not specified otherwise
        self._config = ConfigObj()
        self._config[Config.USER] = ""
        self._config[Config.PASSWORD] = ""
        self._config[Config.HOST] = "localhost"
        self._config[Config.PORT] = 80
        self._config[Config.URI] = "/rpc/api"
        self._config[Config.TOKEN] = ""
        self._config[Config.DEBUG] = ""

I don't know if you were referring the code refers to problems from this part of the config or if it's anything else than that



Do i need to declare the code that you show before?

@port.setter # pylint: disable=E1101 def port(self, value): # pylint: disable=E0102 self._config[Config.PORT] = value



Any feedback is more than appreciated. Thanks everyone :)
~ Rei

pj256 commented 4 months ago

Yes, you will see other setters in /usr/lib/python3.6/site-packages/spacewalk/susemanager/mgr_sync/config.py - search for the text "password.setter" for example. Just add this snippet of code underneath and it will fix it.

P