Python: finding uid/gid for a given username/groupname (for os.chown) -


What is a good method of UID / GID to use Python for a given username or groupname? I need to set file ownership with oshowon and require integer id instead of alphabet. [Quick note]: Get quick access: getpwnam works very well but is not available on windows, so here's some code that makes stubs to allow you to run the same code on windows and unix. Try:

  Try: Meet PWD import except getpwnam: getpwnam = lambda x: (0,0,0) os.chown = lambda x, y, Lambda x, y: true os.fchown = os.chown os.fchmod = os.chmod  

Use more modules:

pwd import getpwnam print getpwnam ('someuser') from [2] # or print getpwnam ('someuser'). Pw_uid


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -