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

return value is none #654

Closed
prasaanth2k opened this issue Oct 4, 2023 · 2 comments
Closed

return value is none #654

prasaanth2k opened this issue Oct 4, 2023 · 2 comments

Comments

@prasaanth2k
Copy link

when we run this code a sudo it is retuning none why?

class Store:
    def __init__(self):
        self.servicename = "your_service_name"
        self.username = "your_username"

    def setkey(self, password):
        keyring.set_password(self.servicename, self.username, password)

    def getkey(self):
        return keyring.get_password(self.servicename, self.username)

    def getsess(self):
        sess = keyring.get_password(self.servicename, self.username)
        return sess

    def deletekey(self):
        if keyring.get_password(self.servicename, self.username):
            if keyring.delete_password(self.servicename, self.username):
                return True
        return False
    
ob = Store()
print(ob.getkey())
# ob.deletekey()`
@jaraco
Copy link
Owner

jaraco commented Nov 12, 2023

Probably something about running under sudo changes the assumptions, such as what settings are in $HOME or what backends are available or what credentials are readable.

@prasaanth2k
Copy link
Author

Yes, bro, that's correct. This keyring works on user basics. When we store the value in the keyring, it also stores it with the current user's name. There are some conditions:

When we store with sudo, and we need to fetch the data with sudo, a normal user can't fetch it.
When we store as a normal user, we can fetch it with sudo. So, it's our decision whether we go with sudo or a normal user.

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

No branches or pull requests

2 participants