On Mon, 2011-06-27 at 10:26 +0800, Yiqiao Pu wrote:
> On 06/27/2011 07:35 AM, Lucas Meneghel Rodrigues wrote:
> > On Sun, Jun 26, 2011 at 12:08 PM, Lucas Meneghel Rodrigues
> > <[email protected]>  wrote:
> >
> >>> +class TransparentHugePageConfig(object):
> >>> +    def __init__(self, test, params):
> >>> +        """
> >>> +        Find paths for transparent hugepages and kugepaged 
> >>> configuration. Also,
> >>> +        back up original host configuration so it can be restored during
> >>> +        cleanup.
> >>> +        """
> >>> +        def file_writeable(file_name):
> >>> +            """
> >>> +            Check if the file is writeable
> >>> +            """
> >>> +            o = utils.system_output("ls -l %s" % file_name)
> >>> +            if re.findall("w", o[0:10]):
> >>> +                return True
> >>> +            return False
> >> ^ This can be replaced with os.access (file_name, os.W_OK)
> > ^ Ok, nevermind, this suggestion didn't quite work as I expected... So
> > in the final version of the code, we'll try to open the file for
> > writing, if an IOError arises, catch it. It's reliable, does the job
> > and we don't need to resort to an external program (in this case, ls).
> Hi Lucas,
> 
> OK. At first time I wrote the script I also use os.access() but find it 
> not work in this case. So I used 'ls' here. But your solution maybe 
> better. It will not depend on the os env. But please make sure the 
> contents you write to the file should be an illegal one, otherwise the 
> default configuration will be changed because of this judgement.

Oh no, don't worry, we'll just try to *open the file for reading* which
means we are not actually writing anything to it, just opening and then
closing it, so no change on the file content at all. I'll post the
version I have here shortly.

Cheers,

Lucas

> 
> Best Regards
> Yiqiao Pu


_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to