Article View: pl.comp.lang.python
Article #15777Re: partycja w trybie ro/rw
From: Rob Wolfe
Date: Sat, 17 Jun 2006 18:47
Date: Sat, 17 Jun 2006 18:47
31 lines
1463 bytes
1463 bytes
Tomasz Wendlandt <juggler@7thguard.net> writes:
> Witam,
>
> Jak najlatwiej sprawdzic w pythonie czy dana partycja jest
> podmontowana w trybie read-only/read-write?
Zakładjąc że chodzi Ci o uniksopodobny system operacyjny,
to można spróbować tak:
<code>
import os, re
from string import strip
pat_ro = re.compile(r'(?<=[,\(])\bro\b')
def is_ro(part):
return pat_ro.search(part.split()[5])
s = os.popen("mount", "r").read()
partitions = s.split("\n")
partitions = filter(strip, partitions)
partitions = filter(None, partitions)
partitions = filter(is_ro, partitions)
print "\n".join(partitions)
</code>
--
pozdrawiam
Rob
Technical Details
Message-ID:
<874pyj7h5w.fsf@smsnet.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<e71enr$dk8$1@atlantis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Rob Wolfe <rw@smsnet.pl> Newsgroups: pl.comp.lang.python Subject: Re: partycja w trybie ro/rw Date: Sat, 17 Jun 2006 20:47:55 +0200 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 31 Message-ID: <874pyj7h5w.fsf@smsnet.pl> References: <e71enr$dk8$1@atlantis.news.tpi.pl> NNTP-Posting-Host: sun2.smsnet.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1150569981 24059 217.97.214.2 (17 Jun 2006 18:46:21 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Sat, 17 Jun 2006 18:46:21 +0000 (UTC) Cancel-Lock: sha1:f8TF/wNNo27SaiX8RRIB5IgNTQ8= X-User: rw8899 User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit