[Tutor] file permissions
Looking for easiest way to get a files permissions in linux. Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file permissions
On Wed, 7 Dec 2005, Eric Walker wrote: Looking for easiest way to get a files permissions in linux. Hi Eric, What have you looked at so far? One of the first hits to the Google query file permission python comes up with some good information: http://www.faqts.com/knowledge_base/view.phtml/aid/5707/fid/552 Forgive me: I'm giving you a hard time only because it didn't look like you did anything yourself yet. Next time you ask a question, also try to show what you've tried so far to find an answer, so that we know we're not following avenues that you've already pursued. We want to make sure you know how to look for answers. If the existing documentation sucks (and some of Python's documentation does need more work!), then we want to know that too so that we can help improve it by sending comments to the Documentation team. In summary, there's file permission stuff we can extract using the 'stat()' function in the 'os' module: http://www.python.org/doc/lib/os-file-dir.html#l2h-1629 The values we get back from os.stat() are a little obscure, but we can interpret the results using the 'stat' module: http://www.python.org/doc/lib/module-stat.html I'm not sure if there's nicer interface to the permission bits; most material I see on it looks fairly low-level. If you have more questions, please feel free to ask. (But please show what work you've tried so far; that way, we have a better idea of your context.) Good luck! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file permissions
On Wed, Dec 07, 2005 at 11:52:20AM -0800, Danny Yoo wrote: On Wed, 7 Dec 2005, Eric Walker wrote: Looking for easiest way to get a files permissions in linux. Hi Eric, What have you looked at so far? I agree with Danny, the question lacks any evidence of prior investigation on the part of the poster, and that makes it a lousy candidate for the helpful guidance of the python tutor list. The documentation on this aspect of python, however, is pretty sparse, and the answer's not exactly intuitive, so I thought I'd mention the effbot's page about the os module as a good place to look, in addition to the documentation Danny listed. http://effbot.org/librarybook/os.htm What he's written there should be able to answer your question. If I may hijack the thread, does anyone more knowledgeable than me know why os.stat and stat are so low-level and esoteric? Am I crazy for wanting to replace oct(stat.S_IMODE(os.stat(thefile)[stat.ST_MODE])) with, say, stat.getmode(os.stat(thefile)) or even os.getmode(thefile) ? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file permissions
Sorry for the bad question. I did google and found the same pages that Danny mentioned. Just couldn't get the stuff to work, or understand what modules needed to be imported to get them to work. I typically use the tutor list as a last resort. After 4+ hours of playing around with this I made the futile post. On Wednesday 07 December 2005 01:42 pm, Gabriel Farrell wrote: On Wed, Dec 07, 2005 at 11:52:20AM -0800, Danny Yoo wrote: On Wed, 7 Dec 2005, Eric Walker wrote: Looking for easiest way to get a files permissions in linux. Hi Eric, What have you looked at so far? I agree with Danny, the question lacks any evidence of prior investigation on the part of the poster, and that makes it a lousy candidate for the helpful guidance of the python tutor list. The documentation on this aspect of python, however, is pretty sparse, and the answer's not exactly intuitive, so I thought I'd mention the effbot's page about the os module as a good place to look, in addition to the documentation Danny listed. http://effbot.org/librarybook/os.htm What he's written there should be able to answer your question. If I may hijack the thread, does anyone more knowledgeable than me know why os.stat and stat are so low-level and esoteric? Am I crazy for wanting to replace oct(stat.S_IMODE(os.stat(thefile)[stat.ST_MODE])) with, say, stat.getmode(os.stat(thefile)) or even os.getmode(thefile) ? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Eric Walker EDA/CAD Engineer Work: 208-368-2573 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file permissions
On Wed, Dec 07, 2005 at 02:51:55PM -0700, Eric Walker wrote: After 4+ hours of playing around with this I made the futile post. Don't let the post be futile! Post what you've tried so far and you'll get help. gsf ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] file permissions
Looking for easiest way to get a files permissions in linux. look at the os.stat function. I'm in the middle of documenting its use but you might like to peruse the later sections of the following draft topic http://www.freenetpages.co.uk/hp/alan.gauld/tutos.htm Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor